Skip to content

Gate legacy span attributes behind UseLegacyAttributes flag - #3747

Merged
ChrisJBurns merged 1 commit into
mainfrom
otel/pr2a-feature-flag-legacy
Feb 10, 2026
Merged

ChrisJBurns merged 1 commit into
mainfrom
otel/pr2a-feature-flag-legacy

Conversation

@ChrisJBurns

Copy link
Copy Markdown
Collaborator

Summary

  • Wraps all existing span attribute emissions in if m.config.UseLegacyAttributes conditionals
  • This is a behavioral no-op since UseLegacyAttributes defaults to true
  • Prepares the codebase for adding new OTEL semantic convention attribute names alongside legacy ones
  • Adds test coverage for both UseLegacyAttributes=true and UseLegacyAttributes=false paths

This 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 UseLegacyAttributes config flag).

Test plan

  • New unit test: TestHTTPMiddleware_LegacyAttributes_Enabled — verifies all legacy attributes emitted when flag is true
  • New unit test: TestHTTPMiddleware_LegacyAttributes_Disabled — verifies no legacy attributes emitted when flag is false
  • Integration test updated with UseLegacyAttributes: true
  • task lint passes
  • task test passes

🤖 Generated with Claude Code

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>
@codecov

codecov Bot commented Feb 10, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 89.18919% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 66.35%. Comparing base (cf2c338) to head (7ea5486).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
pkg/telemetry/middleware.go 89.18% 2 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ChrisJBurns
ChrisJBurns merged commit b9af6fc into main Feb 10, 2026
36 checks passed
@ChrisJBurns
ChrisJBurns deleted the otel/pr2a-feature-flag-legacy branch February 10, 2026 15:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants