Skip to content

Conversation

robbkidd
Copy link
Member

@robbkidd robbkidd commented Jul 10, 2024

Now that semconv won't have deprecated names removed without a major version bump, here's a go at updating semantic conventions to 1.25.

  • no const_missing hijinks! (like in 🚧 WIP: update semantic conventions in a non-breaking way #1567)

  • pulls from the new semconv repo

  • updates jinja2 template for the new structure of convention data

  • stable semconv names will appear in OpenTelemetry::SemanticConventions
    while all semconv names (experimental, deprecated, stable, etc) appear
    in OpenTelemetry::SemanticCandidates

    • This maps to what other langs (Java, Python, JS) are putting into
      "Incubating" modules. We opted for "candidates" because
      OpenTelemetry::SemanticConventions::Incubating::... was getting
      too long and OpenTelemetry::SemanticIncubating didn't make much
      sense.
  • generates a module per root semconv namespace to make navigating docs
    more focused and to decrease the number of constants loaded when
    using more precise requires in downstream code

  • generates only attribute name constants and to an attributes subfolder
    to prepare for metric name constants to be generated to metrics
    subfolders, also for decreasing the scope of what gets loaded when
    downstream instrumentation requires these constants

Some TODOs

A few of these appear in the code in this PR, too.

  • usage examples. How weird is it to explicitly require the nested modules?
  • test(s) to make sure the trace and resource constants are present in SemanticCandidates
    • See dc42bf5. I did the best I could with a test to find which existing v1.10 constants had no match in the entirety of 1.25. I used that list of missing consts to update their deprecation notices accordingly.
  • test(s) to make sure the SemanticConventions (stable) constants are all still present in the SemanticCandidates constants
  • add deprecation notices to all the SemanticConventions::(Resource|Trace) constants with pointers to their replacements
  • figure out how to Firstcap or PascalCase the module names in the jinja2 template with exceptions for things like AspNetCore, HTTP, etc?
    • The module name will become a part of the constants interface, so the fancier we make the code generation logic, the more likely something breaks and we release a version where module names have a new backwards-breaking shape.
    • 👎🏻 I vote we don't do this and have non-idiomatic SCREAMING module names for simplicity of up-keep.
  • Do something about JRuby
    • Turn off testing constants exist on JRuby?
    • Find a markdown parser/renderer (1) supported by Yard, (2) supports inline-code-blocks-inside-links in markdown content, and (3) works on JRuby?
      • Found kramdown. Using it instead of redcarpet.

@robbkidd robbkidd self-assigned this Jul 10, 2024
@robbkidd robbkidd changed the title 🚧 WIP: update semantic conventions in a non-breaking way (take 2) 🚧 semconv 1.26: update in a non-breaking way (take 2) Jul 10, 2024
@robbkidd
Copy link
Member Author

Probably going to dial this back from semconv v1.26 to v1.25 because there's some name hijinks going on in db.* in 1.26. At least for this initial cut at catching Ruby's semconv library up to recent.

@robbkidd robbkidd force-pushed the semconv-update-to-1-26 branch from 7e2cdf2 to 64a9864 Compare July 12, 2024 16:37
@robbkidd
Copy link
Member Author

Guh. New markdown processor (redcarpet) for yard to use in doc generation doesn't support JRuby because native extensions.

An error occurred while installing redcarpet (3.6.0), and Bundler cannot
continue.

In Gemfile:
  redcarpet

@robbkidd robbkidd changed the title 🚧 semconv 1.26: update in a non-breaking way (take 2) 🚧 semconv 1.25: update in a non-breaking way (take 2) Jul 12, 2024
@robbkidd robbkidd changed the title 🚧 semconv 1.25: update in a non-breaking way (take 2) semconv 1.25: update in a non-breaking way (take 2) Jul 12, 2024
@robbkidd robbkidd marked this pull request as ready for review July 12, 2024 16:56
@robbkidd
Copy link
Member Author

robbkidd commented Jul 12, 2024

Taking this out of draft. It may not be ready to merge, but it's ready for people to review and form opinions about.

There's a lot going on here†, so walking the commits might help. I left notes about the whats and whys of each change in the commit messages.

† 😅
Screenshot 2024-07-12 at 1 02 27 PM

@robbkidd robbkidd changed the title semconv 1.25: update in a non-breaking way (take 2) semconv 1.25: update in a non-breaking way Jul 12, 2024
@robbkidd robbkidd force-pushed the semconv-update-to-1-26 branch 2 times, most recently from 97daf90 to 0446676 Compare July 19, 2024 18:30
@robbkidd
Copy link
Member Author

I wondering if some const_missing hijinks ought to be introduced to these Modules to protect downstream developers from semconv schema mistakes or mind-changes that remove attribute names from a version which would result in a missing constant that existed previously. If only to warn-log the missing constant once and return something that (1) prevents runtime code from blowing up and (2) gives some indication of unhappiness in the emitted telemetry that humans actually look at.

@JamieDanielson
Copy link
Member

  • stable semconv names will appear in OpenTelemetry::SemanticConventions
    while all semconv names (experimental, deprecated, stable, etc) appear
    in OpenTelemetry::SemanticCandidates

    • This maps to what other langs (Java, Python, JS) are putting into
      "Incubating" modules. We opted for "candidates" because
      OpenTelemetry::SemanticConventions::Incubating::... was getting
      too long and OpenTelemetry::SemanticIncubating didn't make much
      sense.

Wanted to note while I'm looking at it - there's a chance we may go with Incubating in JS. If we do, it may be worth reconsidering "candidates" to help with consistency, and also to follow what seems to be guidance provided from semconv on artifact structure

  • Artifact name:
    • opentelemetry-semconv - stable conventions
    • opentelemetry-semconv-incubating - (if applicable) the preview artifact containing all (stable and experimental) conventions
  • Namespace: opentelemetry.semconv and opentelemetry.semconv.incubating

So maybe OpenTelemetry::SemConvIncubating:: as an option?

@kaylareopelle
Copy link
Contributor

@JamieDanielson - I like the idea of mirroring the package name more closely and reducing SemanticConventions to SemConv. That'd give our fingers a bit of a break.

So to match the artifact namespace more closely, it could also be:
OpenTelemetry::SemConv - stable constants
OpenTelemetry::SemConv::Incubating - others

@robbkidd
Copy link
Member Author

robbkidd commented Aug 1, 2024

Yea. "Candidates" was probably never going to fly. This whole thing is about trying to be conventional.

I don't hate shortening SemanticConventions to SemConv, especially if we follow the guidance below and generate OpenTelemetry::SemConv::Incubating::Attributes::CLIENT::CLIENT_SOMETHING.

  • Attributes, metrics, and other convention definitions should be grouped by the convention type and the root namespace. See the example below:
├── SchemaUrls.code
├── attributes
│   ├── ClientAttributes.code
│   ├── HttpAttributes.code
│   └── ...
├── metrics
│   ├── HttpMetrics.code
│   └── ...
└── events
    └── ...

Copy link
Contributor

github-actions bot commented Sep 1, 2024

👋 This pull request has been marked as stale because it has been open with no activity. You can: comment on the issue or remove the stale label to hold stale off for a while, add the keep label to hold stale off permanently, or do nothing. If you do nothing this pull request will be closed eventually by the stale bot

@github-actions github-actions bot added the stale label Sep 1, 2024
robbkidd and others added 14 commits April 22, 2025 09:44
    277 runs, 500 assertions, 26 failures, 0 errors, 0 skips

Apparently there are some kinks to work out.
There's naming hijinks in the db.* namespace I would like to avoid in
this first effort to bring semconv up-to-recent-date.
Explain the auto-generated situation.
The v1.10 names whose comments were updated in this commit were renamed
or removed in version 1.11-1.25. Made note of their replacements or that
their use should be dropped.

Removed test for one-to-one matching of 1.10 constants to 1.25 "all"
constants. That will never pass without updating the source semconv YAML
to add back the missing names with dep notices. I believe our dep notes
will suffice and we won't auto-generate Resource or Trace again.
* Move to a tmp/ dir and ignore that.

* Update the git commands to be able to reuse one directory for
  the repo working copy, just update what's needed for a different
  tag between iterations. (Generally only an improvement for dev envs.)

* Use sh() for shell commands so that tasks fail if their commands fail.

* Appease Rubocop.
Co-authored-by: Kayla Reopelle <[email protected]>
Yard's default use of the rdoc markdown provider was choking on links
containing codeblocks, for example: [`ENV`](link/to/somewhere). These
style links are pretty popular in the text details provided with semconv
attributes.

Let's switch to kramdown which is a markdown parser and
renderer that:

* can handle inline code blocks inside a link anchor
* is pure Ruby (no C extensions) so works with JRuby
* out with Candidates, we're using Incubating like most other SIGs
* shorten the namespace to SemConv
* do not provide an all-in-one rollup require for all namespaces;
  downstream users must directly require the namespaces that they use
* attributes that are templates (prefixes, really, for the moment) are
  generated as lambdas with _LAMBDA appended to their name; users must
  call that lambda with a key for the template to return the attribute
  name string
With multiple template entries in weaver.yaml, code generation for
stable and incubating can be performed in one invocation of the docker
image. Rakefile targets trimmed down in light of that.
Each root namespace gets separate attributes and metrics files.

Include examples of possible values for attributes.

Include a usage example of the template attributes as lambdas.

Fix links in doc comments referencing stable constants.

Co-authored-by: Hannah Ramadan <[email protected]>
Co-authored-by: Kayla Reopelle <[email protected]>
* Layout/HeredocIndentation: Use 2 spaces for indentation in a
  heredoc.
* Style/StringLiterals: Prefer single-quoted strings when you don't
  need string interpolation or special symbols.

* Style/StringConcatenation: Prefer string interpolation to string
  concatenation.
  - ... except we don't want *interpolation*; we want to join pathname
  components with the correct separator for the operating system. So
  we'll use Pathname.join explicitly instead of Pathname's :+ operator
  so Rubocop doesn't think we're concatonating strings.
* Style/RedundantCurrentDirectoryInPath: Remove the redundant
  current directory path
* Style/RedundantFileExtensionInRequire: Redundant .rb file
  extension detected.
@robbkidd robbkidd force-pushed the semconv-update-to-1-26 branch from 5708734 to e8357d8 Compare April 22, 2025 19:58
@robbkidd robbkidd changed the title semconv 1.25: update in a non-breaking way feat(semconv): update to v1.25 in a non-breaking way Apr 22, 2025
@kaylareopelle
Copy link
Contributor

Following up from Slack, here's a PR with my tweaks that bump the version to 1.36.0, which was the latest semconv version last week.

robbkidd#1

The script worked great! I made a few small tweaks to account for formatting (rubocop) and the tests. Otherwise, this seems very easy to maintain as long as weaver remains stable. I'm comfortable approving this PR with those changes. I think we should also update the README to reflect this new structure, which I would be happy to do.

What else do we need to consider before we merge this? What am I missing?

@robbkidd
Copy link
Member Author

robbkidd commented Aug 28, 2025

robbkidd#1

Merged!

What else do we need to consider before we merge this? What am I missing?

The questions we've asked ourselves in this PR that I don't know the answers to:

  • in the description:
    • provide usage examples?
      • 🗳️ Maybe not a blocker, can be done later?
    • camelCase or SnakeCase constant names?
      • 🗳️ I vote no and for us to go with the current SCREAMING.
  • in a pairing recap of old:
    • distinguish constants for attribute names vs metric names?
      • 🗳️ No? I think the only danger of not doing so is the risk that an attribute and a metric comes along at some point with the same name. 🤔 Which would mean one constant wins … but their names would be the same, so I think the result in telemetry produced would be indistinguishable. We'd just have an annoying warning at load time about a constant getting redefined.
    • making the generated documentation a little better with hyperlinking
      • 🗳️ I think at this point we shouldn't let gold-plated† docs block merging this PR to get up-to-date constants out to folks.

† And I think this as the primary gold-plater here.

@robbkidd
Copy link
Member Author

robbkidd commented Aug 28, 2025

Guh. Linters, amirite?

@kaylareopelle
Copy link
Contributor

Guh. Linters, amirite?

Ughhhh I forgot to run rubocop locally before I opened the PR. 🫠

At least the problems are only related to human-written code and not the autogenerated stuff! I'll add some code suggestions to fix things up.

@kaylareopelle
Copy link
Contributor

The questions we've asked ourselves in this PR that I don't know the answers to:

  • in the description:

    • provide usage examples?

      • 🗳️ Maybe not a blocker, can be done later?
    • camelCase or SnakeCase constant names?

      • 🗳️ I vote no and for us to go with the current SCREAMING.

Yup. +1 here. Let's leave it.

  • in a pairing recap of old:

    • distinguish constants for attribute names vs metric names?

      • 🗳️ No? I think the only danger of not doing so is the risk that an attribute and a metric comes along at some point with the same name. 🤔 Which would mean one constant wins … but their names would be the same, so I think the result in telemetry produced would be indistinguishable. We'd just have an annoying warning at load time about a constant getting redefined.

Also agree!

  • making the generated documentation a little better with hyperlinking

    • 🗳️ I think at this point we shouldn't let gold-plated† docs block merging this PR to get up-to-date constants out to folks.

† And I think this as the primary gold-plater here.

I think that's a good call. We can create an issue to take care of this later on if we feel strongly about it.

Bundler/OrderedGems: Gems should be sorted in an alphabetical order within their section of the Gemfile.

Minitest/EmptyLineBeforeAssertionMethods: Add empty line before assertion.

Co-authored-by: Kayla Reopelle <[email protected]>
Copy link
Contributor

@kaylareopelle kaylareopelle left a comment

Choose a reason for hiding this comment

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

🎊

@kaylareopelle
Copy link
Contributor

Whenever we want to look at README improvements, here's a draft: robbkidd#2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
keep spec-compliance Required for OpenTelemetry spec compliance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants