Skip to content

Avoid unnecessary log allocations in B3 multi-header extraction - #9073

Open
Eliot5566 wants to merge 2 commits into
open-telemetry:mainfrom
Eliot5566:b3-no-alloc-missing-trace-id
Open

Eliot5566 wants to merge 2 commits into
open-telemetry:mainfrom
Eliot5566:b3-no-alloc-missing-trace-id

Conversation

@Eliot5566

Copy link
Copy Markdown

Summary

Avoid unnecessary logging and string allocations when extracting B3 multi-header trace context.

Changes

  • Return early without logging when the trace ID header is missing, consistent with the single-header extractor.
  • Use parameterized logging for invalid IDs to avoid string construction when logging is disabled.
  • Fix an unmatched quotation mark in the existing log message.

Testing

  • Added two LogUnit regression tests.
  • 20 of 21 CI jobs passed on my fork. The remaining macOS Java 8 job is awaiting a runner and has not failed.

Fixes #9065

I used Claude to help write and test this change.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3

B3PropagatorExtractorMultipleHeaders built a log message on every
extract() call without an X-B3-TraceId header, even with FINE logging
off, so every untraced request allocated a string. Return early when the
header is absent, as the single header extractor does, and use
parameterized log calls for invalid trace and span IDs.

Fixes open-telemetry#9065

Claude-Session: https://claude.ai/code/session_01Hq1ACTsK85bRrY28fUQ7b3
@Eliot5566
Eliot5566 requested a review from a team as a code owner November 27, 2026 08:08
@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-11-27 08:57 UTC

Review the latest changes.

Status above doesn't look right?
  • Just replied or pushed? Anything around or after the refresh time above may not be picked up yet — give it a few minutes.
  • Should this be with the author? Comment /dashboard route:author to route it back.
  • Anything wrong — including the routing? Report it with what you expected; it helps us improve the dashboard.

@codecov

codecov Bot commented Nov 27, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.56%. Comparing base (a92b644) to head (6f5b70b).

Additional details and impacted files
@@            Coverage Diff            @@
##               main    #9073   +/-   ##
=========================================
  Coverage     90.56%   90.56%           
- Complexity    11220    11221    +1     
=========================================
  Files          1032     1032           
  Lines         30599    30601    +2     
  Branches       4010     4011    +1     
=========================================
+ Hits          27711    27713    +2     
  Misses         1913     1913           
  Partials        975      975           

☔ View full report in Codecov by Harness.
📢 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.

This branch has not been deployed

No deployments
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.

B3PropagatorExtractorMultipleHeaders allocates when headers are missing

1 participant