Gate legacy span attributes behind UseLegacyAttributes flag - #3747
Merged
Merged
Conversation
Wrap all existing span attribute emissions in conditional blocks controlled by the UseLegacyAttributes config flag. Since the flag defaults to true, this is a behavioral no-op — all the same attributes are still emitted. This structural change prepares for the follow-up PR that adds new OTEL semantic convention attribute names alongside the legacy names. Attributes gated (emitted only when UseLegacyAttributes=true): - HTTP: http.method, http.url, http.scheme, http.host, http.target, http.user_agent, http.request_content_length, http.query, http.status_code, http.response_content_length, http.duration_ms - MCP: mcp.method, rpc.system, rpc.service, mcp.request.id, mcp.resource.id, mcp.transport - Method-specific: mcp.tool.name, mcp.tool.arguments, mcp.resource.uri, mcp.prompt.name, mcp.client.name Attributes kept unconditional (not renamed in follow-up): - mcp.server.name, mcp.is_batch, sse.event_type - Span status (Ok/Error) Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
ChrisJBurns
requested review from
JAORMX,
jerm-dro and
yrobla
as code owners
February 10, 2026 15:20
This was referenced Feb 10, 2026
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3747 +/- ##
==========================================
+ Coverage 66.31% 66.35% +0.04%
==========================================
Files 427 427
Lines 41800 41807 +7
==========================================
+ Hits 27718 27743 +25
+ Misses 11971 11951 -20
- Partials 2111 2113 +2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
jhrozek
approved these changes
Feb 10, 2026
This was referenced Feb 10, 2026
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
if m.config.UseLegacyAttributesconditionalsUseLegacyAttributesdefaults totrueUseLegacyAttributes=trueandUseLegacyAttributes=falsepathsThis is a structural change only — no attributes are renamed or added. When
UseLegacyAttributes=true(the default), all existing attributes are emitted exactly as before.Stacked on #3729 (adds the
UseLegacyAttributesconfig flag).Test plan
TestHTTPMiddleware_LegacyAttributes_Enabled— verifies all legacy attributes emitted when flag is trueTestHTTPMiddleware_LegacyAttributes_Disabled— verifies no legacy attributes emitted when flag is falseUseLegacyAttributes: truetask lintpassestask testpasses🤖 Generated with Claude Code