Skip to content

feat: http semconv opt in files #1547

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

Conversation

hannahramadan
Copy link
Contributor

@hannahramadan hannahramadan commented May 22, 2025

This PR is intended to assist in the transition from the old to new HTTP semantic conventions. Per the HTTP semantic convention stability migration spec, users should be able to set the environment variable OTEL_SEMCONV_STABILITY_OPT_IN to:

  • http to emit stable conventions only
  • http/dup to emit both old and the stable conventions
  • a blank env var will emit old conventions only

The agent is required to maintain this bridge for 6 months and may drop the environment variable in the next major version and emit only the stable HTTP and networking conventions.

While this approach introduces multiple new and similar files and tests (potentially making debugging and maintenance more difficult), the tradeoff ensures we're only patching the HTTP class once and makes the eventual cleanup of the old conventions mostly a matter of deleting files and small refactors. Another approach (also taken by Python) introduces a StabilityMode class that checks calls to determine which attributes to send, however this approach adds complexity of calling a method every time an attribute is added.

Hopefully with the temporary nature of this work, this solution can be seen as a way to start the transition. The approach can also be easily duplicated to other HTTP libraries and support the similar DB migration.

@hannahramadan hannahramadan changed the title Http semcon opt in files feat: http semcon opt in files May 27, 2025
@hannahramadan hannahramadan changed the title feat: http semcon opt in files feat: http semconv opt in files May 27, 2025
::HTTP::Connection.prepend(Patches::Connection)
def determine_semconv
case ENV.fetch('OTEL_SEMCONV_STABILITY_OPT_IN', nil)
when 'http/dup'
Copy link
Contributor Author

Choose a reason for hiding this comment

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

http/dup takes precedence, so we check this first.

'server.address' => uri.host,
'server.port' => uri.port
}
attributes['url.query'] = uri.query unless uri.query.nil?
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Queries weren't previously reported and can often be nil, so we check/add this attribute separately.


semconv_stability = %w[dup stable old]

semconv_stability.each do |mode|
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This approach gives us a fresh HTTP instance on each run. Without this, a single HTTP instance receives all patches.

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.

I love the simplicity of this approach, especially since we're only required to keep it for six months. Migrating to the stable semantic conventions also makes metrics integration much easier. Thank you!

@kaylareopelle
Copy link
Contributor

We're planning to merge this on Monday, June 16 if there are no blocking comments.

@kaylareopelle kaylareopelle enabled auto-merge (squash) June 17, 2025 17:15
@kaylareopelle kaylareopelle merged commit 7837db8 into open-telemetry:main Jun 17, 2025
61 of 62 checks passed
Copy link

@MurdoqZodoq MurdoqZodoq left a comment

Choose a reason for hiding this comment

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

GitHub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants