-
Notifications
You must be signed in to change notification settings - Fork 353
First stab at documenting the art of defining semantic conventions #1707
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
lmolkova
merged 15 commits into
open-telemetry:main
from
lmolkova:how-to-contribute-new-conventions
Jan 31, 2025
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
fccfa7c
Add first version of semconv guidance
447c2e6
toc
e41fd0d
up
152fa7a
clean up
a86b248
lint
993aca5
feedback: part1
e599d0f
feedback: part2
ea9cdda
feedback
d3da146
Apply suggestions from code review
d09cce3
feedback
a12495a
Merge branch 'main' into how-to-contribute-new-conventions
trisch-me 052f267
Merge branch 'main' into how-to-contribute-new-conventions
trask 07be266
Update docs/general/how-to-define-semantic-conventions.md
1638728
Merge branch 'main' into how-to-contribute-new-conventions
72c9eba
Update docs/general/how-to-define-semantic-conventions.md
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,154 @@ | ||
| <!--- Hugo front matter used to generate the website version of this page: | ||
| linkTitle: How to define new semantic conventions | ||
| ---> | ||
|
|
||
| # How to define new semantic conventions | ||
|
|
||
| **Status**: [Development][DocumentStatus] | ||
|
|
||
| <!-- toc --> | ||
|
|
||
| - [Defining new conventions](#defining-new-conventions) | ||
| - [Best practices](#best-practices) | ||
| - [Defining attributes](#defining-attributes) | ||
| - [Defining spans](#defining-spans) | ||
| - [Defining metrics](#defining-metrics) | ||
| - [Defining resources](#defining-resources) | ||
| - [Defining events](#defining-events) | ||
| - [Stabilizing existing conventions](#stabilizing-existing-conventions) | ||
| - [Migration plan](#migration-plan) | ||
|
|
||
| <!-- tocstop --> | ||
|
|
||
| This document describes requirements, recommendations, and best practices on how to define conventions | ||
| for new areas or make substantial changes to the existing ones. | ||
|
|
||
| ## Defining new conventions | ||
|
|
||
| - New conventions MUST have a group of codeowners. See [project management](https://github.com/open-telemetry/community/blob/main/project-management.md) for more details. | ||
| <!-- TODO: add CI check for CODEOWNERS file (when a new area is added) --> | ||
| - New conventions SHOULD be defined in YAML files. See [YAML Model for Semantic Conventions](/model/README.md) for the details. | ||
| - New conventions SHOULD be defined with `development` stability level. | ||
| - New conventions SHOULD include telemetry signal definitions (spans, metrics, events, resources, profiles) and MAY include new attribute definitions. | ||
|
|
||
| ### Best practices | ||
|
|
||
| > [!NOTE] | ||
| > | ||
| > This section contains non-normative guidance. | ||
|
|
||
| #### Defining attributes | ||
|
|
||
| Reuse existing attributes when possible. Look through [existing conventions](/docs/attributes-registry/) for similar areas, | ||
| check out [common attributes](/docs/general/attributes.md). | ||
| Semantic conventions authors are encouraged to use attributes from different namespaces. | ||
|
|
||
| Consider adding a new attribute if all of the following apply: | ||
|
|
||
| - It provides a clear benefit to end users by enhancing telemetry. | ||
| - There is a clear plan to use the attributes when defining spans, metrics, events, resources, or other telemetry signals in semantic conventions. | ||
| - There is a clear plan on how these attributes will be used by instrumentations | ||
|
trisch-me marked this conversation as resolved.
|
||
|
|
||
| Semantic convention maintainers may reject the addition of a new attribute if its benefits | ||
| and use-cases are not yet clear. | ||
|
|
||
| When defining a new attribute: | ||
|
|
||
| - Follow the [naming guidance](/docs/general/naming.md) | ||
| - Provide descriptive `brief` and `note` sections to clearly explain what the attribute represents. | ||
| - If the attribute represents a common concept documented externally, include relevant links. | ||
| For example, always link to concepts defined in RFCs or other standards. | ||
| - If the attribute's value might contain PII or other sensitive information, explicitly call this out in | ||
| the `note`. | ||
|
|
||
| Include a warning similar to the following: <!-- TODO: update existing semconv --> | ||
|
|
||
| ```yaml | ||
| - id: user.full_name | ||
| ... | ||
| note: | | ||
| ... | ||
|
|
||
| > [!WARNING] | ||
| > | ||
| > This attribute contains sensitive (PII) information. | ||
| ``` | ||
|
|
||
| - Use the appropriate [attribute type](https://github.com/open-telemetry/weaver/blob/main/schemas/semconv-syntax.md#type) | ||
| - If the value has a reasonably short (open or closed) set of possible values, define it as an enum. | ||
| - If the value is a timestamp, record it as a string in ISO 8601 format. | ||
| - For arrays of primitives, use the array type. Avoid recording arrays as a single string. | ||
| - Use the template type to define attributes with dynamic names (only the last segment of the name should be dynamic). | ||
| This is useful for capturing user-defined key-value pairs, such as HTTP headers. | ||
| - Represent complex values as a set of flat attributes. <!-- This may change, check out https://github.com/open-telemetry/semantic-conventions/issues/1669 to monitor the progress --> | ||
| - Define new attributes with `development` stability. | ||
| - Provide realistic examples | ||
| - Avoid defining attributes with potentially unbounded values, such as strings longer than | ||
| 1 KB or arrays with more than 1,000 elements. Such values should be recorded in the log or event body instead. <!-- This may change, check out https://github.com/open-telemetry/semantic-conventions/issues/1651 to monitor the progress --> | ||
|
|
||
| Consider the scope of the attribute and how it may evolve in the future: | ||
|
|
||
| - When defining an attribute for a narrow use case, think about potential broader use cases. | ||
| For example, if creating a system-specific attribute, evaluate whether other systems | ||
| in the same domain might need a similar attribute in the future. | ||
|
|
||
| Similarly, instead of defining a simple boolean flag indicating a success or failure, consider a | ||
| more extensible approach, such as using a `foo.status_code` attribute to include additional details. | ||
|
|
||
| - When defining a broad attribute applicable across multiple domains or systems, | ||
| check for existing standards or widely accepted best practices in the industry. | ||
| Avoid creating generic attributes that are not based on established standards. | ||
|
|
||
| > [!NOTE] | ||
| > | ||
| > When defining conventions for areas with multiple implementations or systems — such as databases, | ||
| > or cloud providers — it can take time to strike the right balance between being | ||
| > overly generic and not generic enough. | ||
| > | ||
| > Start with experimental conventions, document how they apply to a diverse range | ||
| > of providers, systems, or libraries, and prototype instrumentations. | ||
| > | ||
| > The end-user experience should serve as the primary guiding principle: | ||
| > | ||
| > - If the attribute is expected to be used in general-purpose metrics for the area, | ||
| > consider introducing a common attribute. | ||
| > | ||
| > For example, most messaging systems have a concept like a queue or topic. | ||
| > Queue or topic names are critical for latency and throughput metrics and | ||
| > equally important for spans to debug and visualize message flow. | ||
| > This indicates the need for a generic attribute representing any type of messaging destination. | ||
| > | ||
| > - If the attribute represents something useful in a narrow set of scenarios or | ||
| > is specific to certain system metrics, spans, or events, it likely does not need to be generic. | ||
|
|
||
| #### Defining spans | ||
|
|
||
| TBD | ||
|
|
||
| #### Defining metrics | ||
|
|
||
| TBD | ||
|
|
||
| #### Defining resources | ||
|
|
||
| TBD | ||
|
|
||
| #### Defining events | ||
|
|
||
| TBD | ||
|
|
||
| ## Stabilizing existing conventions | ||
|
|
||
| - All conventions MUST be defined in YAML before they can be declared stable | ||
| - Conventions that are not used by instrumentations MUST NOT be declared stable | ||
|
|
||
| TODO: | ||
|
|
||
| - prototyping/implementation requirements | ||
| - migration plan | ||
|
|
||
| ### Migration plan | ||
|
|
||
| TODO | ||
|
|
||
| [DocumentStatus]: https://opentelemetry.io/docs/specs/otel/document-status | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.