Skip to content

Latest commit

History

History
28 lines (18 loc) 路 1.61 KB

attribute-naming.md

File metadata and controls

28 lines (18 loc) 路 1.61 KB

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.version聽denotes the service version where聽service聽is the namespace and聽version聽is an attribute in that namespace.
  • Namespaces can be nested. For example聽telemetry.sdk聽is a namespace inside top-level聽telemetry聽namespace and聽telemetry.sdk.name聽is an attribute inside聽telemetry.sdk聽namespace.
  • For each multi-word separate the words by underscores (use snake_case). For example聽http.status_code聽denotes the status code in the http namespace.
  • Names should not coincide with namespaces. For example if聽service.instance.id聽is an attribute name then it is no longer valid to have an attribute named聽service.instance聽because聽service.instance聽is 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鈥檛 want to enforce OTel attribute keys, don鈥檛 enable this rule.