steffan-westcott / clj-otel

An idiomatic Clojure API for adding telemetry to your libraries and applications using OpenTelemetry.
https://cljdoc.org/d/com.github.steffan-westcott/clj-otel-api
Apache License 2.0
183 stars 12 forks source link

Attribute names generated by steffan-westcott.clj-otel.api.attributes/->attributes contain a slash #6

Closed devurandom closed 1 year ago

devurandom commented 1 year ago

https://opentelemetry.io/docs/reference/specification/common/attribute-naming/ says:

Names SHOULD follow these rules:

  • Use namespacing to avoid name clashes. Delimit the namespaces using a dot character. For example service.version denotes the service version where service is the namespace and version is an attribute in that namespace.

but steffan-westcott.clj-otel.api.attributes/->attributes generates names with a slash / character delimiting the namespace instead of the dot . character:

(steffan-westcott.clj-otel.api.attributes/->attributes {:foo/bar 1})
;=> #object[io.opentelemetry.api.common.ArrayBackedAttributes 0x1d4845f0 "{foo/bar=1}"]
steffan-westcott commented 1 year ago

@devurandom Thank you for raising this issue. Originally I intentionally retained the Clojure syntax for separating namespace and name with / for attribute names, but on reflection, I think it is preferable to adopt the OpenTelemetry recommendation.

devurandom commented 1 year ago

I noticed that https://opentelemetry.io/docs/specs/otel/common/attribute-naming/ also proposes snake_case instead of kebab-case, that is more common in Clojure keywords:

For each multi-word dot-delimited component of the attribute name separate the words by underscores (i.e. use snake_case). For example http.status_code denotes the status code in the http namespace.

steffan-westcott commented 1 year ago

@devurandom Thanks for highlighting this naming convention for attributes. I have addressed this shortcoming in this commit.