Skip to content
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

Add conventions for attribute names #807

Conversation

tigrannajaryan
Copy link
Member

Resolves: #726

@tigrannajaryan tigrannajaryan requested review from a team and SergeyKanzhelev August 14, 2020 19:32
@tigrannajaryan tigrannajaryan added the spec:miscellaneous For issues that don't match any other spec label label Aug 14, 2020

### Attribute Naming

Attribute name (also known as the "attribute key") MUST be a valid Unicode
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's limit to printable characters and forbid control ones?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We are opening a different can of worms here, which is #504

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyKanzhelev I wanted to place the minimal restrictions here, then refine them slightly differently in the 2 sub-sections below (and for semantic conventions the limitations are precisely as you listed - only printable ASCII characters). I can remove this sentence since it is somewhat superfluous given additional restrictions listed later in the document.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 I'd like to avoid addressing #504 in this same PR. They are related but don't need to be solved at the same time.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, @tigrannajaryan. I think the restriction of being valid Unicode is OK for a start although maybe even that should be dropped from the PR to not get lost in that discussion.


- Semantic conventions MUST limit attribute names to
[U+0021 .. U+007E](https://en.wikipedia.org/wiki/Basic_Latin_(Unicode_block)#Table_of_characters)
subset of Unicode code points only. It is recommended to further limit
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is unicode code points? Would be nice to have human readable text here

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "the ASCII subset of Unicode" would be more clear. Not sure if it means exactly the same?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyKanzhelev Code point is an official term used by Unicode: https://www.unicode.org/versions/Unicode13.0.0/ch02.pdf#G25564
I could use "character" but "code point" is the correct term in this context when referring to Unicode.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Oberon00 ASCII is a wider range: [U+0000 .. U+007F]. That is not my intent. I want to exclude space and control characters, that's why a reference to that particular range.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyKanzhelev I reworded this sentence slightly, please see if it is clearer now.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is so much better! Thank you

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know from some history that limiting to Latin is not very well recieved from globalization standpoint. But I think we need to state this as a recommendation as it avoids a slew of problems

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SergeyKanzhelev I think it is still the right thing to limit attribute names introduced by OpenTelemetry itself to Latin as it seems to be the common denominator in the programming world. For custom attributes that developers may use in their applications we only recommend Latin, but do not require it so people are still able to use attributes in any language supported by Unicode.

@SergeyKanzhelev SergeyKanzhelev self-assigned this Aug 14, 2020
- All attributes names that are part of OpenTelemetry semantic conventions
SHOULD be part of a namespace.

- When coming up with a new convention make sure to check existing namespaces
Copy link
Member

@Oberon00 Oberon00 Aug 14, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are keys supposed to be unique across all three of these? #739 (comment) seems to not adhere to this principle.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's a good question. I am inclined to say "yes", simply to avoid confusion that will arise if there are attibutes with the same name for a Resource and a Span which mean different things.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Created an issue #815

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/attribute-names branch from e8e6066 to 1d9f7a4 Compare August 14, 2020 23:08
@tigrannajaryan tigrannajaryan requested a review from a team August 14, 2020 23:08
@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/attribute-names branch from 1d9f7a4 to f014f61 Compare August 14, 2020 23:19
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! These definitely make it easier to come up with attribute names.


- The attribute is specific to your application. It is recommended to prefix the
attribute name by your application name, provided that the application name is
resonably unique and is not a generic enough word (e.g.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it important for the app name to be generally unique? If a company has tracing infrastructure shared by many teams, presumably the name just has to not collide with other teams in the company.

Copy link
Member Author

@tigrannajaryan tigrannajaryan Aug 17, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It needs to be unique within the scope where it is intended to be used, unique within the set of applications that can be used together.

Hopefully "reasonably unique" reflects the intent, if not I can clarify.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reasonably unique by itself I think is fine, the following "generic enough word" is where it seems to overspecify to me. If a generic word is unique in the context of that user, that's probably fine.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded.

resonably unique and is not a generic enough word (e.g.
`myuniquemapapp.longitude` is likely fine). Make sure the application name
does not clash with an existing semantic convention namespace. If in doubt
prefix it with your company's reverse domain name.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's rare for traces to have conflicts with traces from other companies, but there may be multiple teams at a company using the same tracing system. Can a company reverse domain name ever help disambiguating attributes?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was thinking about the scenario where a popular application is created by a company and that application may be used outside the company as well. You are right that for purely internal applications this is likely not necessary.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that you may also be applying this guidelines for libraries. Even if it's a public OSS library, it may have very specific attributes that do not warrant standardizing.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From what I understand, this section is about apps, the end users, not libraries which are closer to instrumentation. It is confusing, perhaps there needs to be a section about libraries specifically, perhaps "OpenTelemetry authors" can be made more general to cover general libraries / instrumentation. But I would encourage a general stance of giving end users, presumably the final app developers, more freedom since their UX is what matters in the end. For example, if most of their queries require latitude anyways, there doesn't seem to be a big reason to prevent them from using the latitude attribute by itself unprefixed, since it's what they need. "Do what makes your job easier" seems to be missing from this section right now IMO.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded, PTAL.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reworded one more time to account for @anuraaga 's comment on giving more freedom.

words by underscores (i.e. use snake_case). For example `http.status_code`
denotes the status code in the http namespace.

- Attribute names SHOULD NOT coincide with namespaces. For example if
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

An example just came up which may describe this even more clearly. You can't have attribute service.version and a clarifying attribute service.version.type it needs to be something like service.version.id.

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/attribute-names branch from f014f61 to 64d8449 Compare August 17, 2020 14:42
Copy link
Contributor

@anuraaga anuraaga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@tigrannajaryan tigrannajaryan force-pushed the feature/tigran/attribute-names branch from 6ccdd82 to d26c821 Compare August 17, 2020 15:09
Copy link
Member

@Oberon00 Oberon00 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM but I think #807 (comment) could be controversial.

[Resources](https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/resource/semantic_conventions),
[Spans](https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/trace/semantic_conventions),
and
[Metrics](https://github.com/open-telemetry/opentelemetry-specification/tree/master/specification/metrics/semantic_conventions)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe explicitly state somewhere that label keys are equivalent to attribute keys in the scope of this document.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Submitted #821

@SergeyKanzhelev SergeyKanzhelev merged commit 671f5ab into open-telemetry:master Aug 17, 2020
@tigrannajaryan tigrannajaryan deleted the feature/tigran/attribute-names branch August 17, 2020 17:27
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-specification that referenced this pull request Aug 17, 2020
We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry#807 (comment)
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-specification that referenced this pull request Aug 17, 2020
We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry#807 (comment)
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-specification that referenced this pull request Aug 17, 2020
We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry#807 (comment)
tigrannajaryan pushed a commit to tigrannajaryan/opentelemetry-specification that referenced this pull request Aug 19, 2020
We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry#807 (comment)
@garretwilson
Copy link

garretwilson commented Aug 19, 2020

As the person who raised #726, I'm really happy that some work has been done to clarify this area a bit.

It's a little disappointing that it seems that you're trying to invent some new system on the fly however. Experts in the field have spent decades refining naming systems. For example, the ECMAScript (JavaScript) specification already goes into depth on identifier syntax; this has been developed for years and tested extensively in the field. Was this specification or any other specification consulted?

The discussion and resulting prose indicate some confusion on the fundamentals of Unicode and text representation. For example, limiting of attribute names indicates "code points" when it appears "Unicode Category" was intended. (If you want a crash course on Unicode you might be interested in my lesson on the subject.) And even here the definition is far from rigorous: can I start a name with a number? Can I start a name with an underscore? Can I start a name with a dot??!

That you are essentially limiting names to a subset of ASCII is concerning, placing your specification back around the mid 1990s in its level of syntax sophistication and international support. Again I think it would have been helpful to consult similar metadata and naming specifications, where experts have pored over such details for many years.

Lastly the use of a dot . as a namespace delimiter can cause problems. My guess is that you were following the lead of the Java package delimiter, but the dot is so overloaded that other naming systems use other delimiters. For example XML/HTML/RDF CURIE uses : as a namespace prefix delimiter, and HTML5 with its data- attributes seems to be leaning towards the dash - character as a type of namespace delimiter. Many systems do not allow dots in tokens (what if the tracing library logs to a monitoring system that queries for variable names?), and in some systems the dot is a special character indicating class-property relationship (such as Widget.id).

Let me give you an example using a query language. Configuration files often use the form foo.bar to look up resource keys in Java Properties files or YAML files for instance. The dot represents a level indicator between two tokens, such as in OGNL. (See a hierarchical configuration library as another example.) So for example if I were to have an outer span named outer with a child span named inner, I might want to query for that using outer.inner. But if each of those spans uses . for namespacing such as foo.outer and bar.inner, querying for inner using a dot with foo.outer.bar.inner would be ambiguous. I'm just saying that maybe a dot is not the best choice of a namespace delimiter within a token, based upon common usage of delimiters in modern naming and querying systems.

In any case this is certainly a great step forward and I hope you to keep improving it. I would encourage you look into existing work in the field and not just try to invent everything from scratch in your tiny area of technology, because distributed tracing actually has the potential to interact with many naming and metadata systems across applications.

@tigrannajaryan
Copy link
Member Author

@garretwilson thank you for the comment. Further improvements, especially in the form of PRs are welcome. My PR primarily legalized implicit rules that semantic conventions were already following.

bogdandrutu pushed a commit that referenced this pull request Aug 19, 2020
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment #807 (comment)

* Address PR comments
@tedsuo
Copy link
Contributor

tedsuo commented Aug 19, 2020

Hi @garretwilson, thank you for the feedback!

The dot notation for key names has been a common convention in distributed tracing for years at this point, so unfortunately it is probably here to stay for the foreseeable future (we care a lot about backwards compatibility with existing instrumentation, so dots in the keys will be a gotcha for many years). If there is a better way to do this, we would want it done before GA . But please accept that we may just have to live with dots, albeit hopefully in a more structured and organized fashion. 🙏

Something we are actively interested is adopting/merging with is the Elastic Common Schema. If we could clean up our information architecture to match their conventions and existing definitions, that would be really helpful. (@tigrannajaryan please correct me if something has changed on this front in the Logging SIG). @garretwilson is that something you would be interested in taking on?

jack-berg pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 7, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
AlexanderWert pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 10, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jack-berg pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jack-berg pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jsuereth pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jsuereth pushed a commit to jack-berg/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jsuereth pushed a commit to open-telemetry/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
jsuereth pushed a commit to open-telemetry/semantic-conventions that referenced this pull request Nov 16, 2023
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
joaopgrassi pushed a commit to dynatrace-oss-contrib/semantic-conventions that referenced this pull request Jan 10, 2024
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
joaopgrassi pushed a commit to dynatrace-oss-contrib/semantic-conventions that referenced this pull request Jan 10, 2024
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
pyohannes pushed a commit to pyohannes/semantic-conventions that referenced this pull request Jan 17, 2024
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
pyohannes pushed a commit to pyohannes/semantic-conventions that referenced this pull request Jan 17, 2024
* Extend attribute naming rules to metric labels

We earlier defined naming rules for attributes, however we do not have
similar rules for metric labels. This commit extends the exact same
set of rules to metric labels.

This was brought up in this comment open-telemetry/opentelemetry-specification#807 (comment)

* Address PR comments
carlosalberto pushed a commit to carlosalberto/opentelemetry-specification that referenced this pull request Oct 31, 2024
* Add conventions for attribute names

Resolves: open-telemetry#726

* Address PR comments

* Re-word company/application specific attribute recommendations
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:semantic-conventions Related to semantic conventions spec:miscellaneous For issues that don't match any other spec label
Projects
None yet
Development

Successfully merging this pull request may close these issues.

conventions for names such as attribute names
6 participants