attribute-naming
Enforce attribute keys to follow common specifications.
Rule Detailsβ
An Attribute is a key-value pair, which is encapsulated as part of a span. The attribute key should follow a set of common specifications to be considered valid.
The following OpenTelemetry Semantic Conventions for attribute keys are defined:
- It must be a non-null and non-empty string.
- It must be a valid Unicode sequence.
- It should use namespacing to avoid name clashes. Delimit the namespaces using a dot character. For example
service.versiondenotes the service version whereserviceis the namespace andversionis an attribute in that namespace. - Namespaces can be nested. For example
telemetry.sdkis a namespace inside top-leveltelemetrynamespace andtelemetry.sdk.nameis an attribute insidetelemetry.sdknamespace. - For each multi-word separate the words by underscores (use snake_case). For example
http.status_codedenotes the status code in the http namespace. - Names should not coincide with namespaces. For example if
service.instance.idis an attribute name then it is no longer valid to have an attribute namedservice.instancebecauseservice.instanceis already a namespace.
Optionsβ
This rule has the following options:
"error"requires attribute keys to follow the OTel semantic convention"disabled"disables the attribute keys verification"warning"verifies attribute keys to follow the OTel semantic convention but does not impact the analyzer score
When Not To Use Itβ
If you donβt want to enforce OTel attribute keys, don't enable this rule.