Skip to content

Propagate baggage to the parent context in SpanBuilderShim - #8812

Open
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/opentracing-shim-parent-context-baggage
Open

Propagate baggage to the parent context in SpanBuilderShim#8812
thswlsqls wants to merge 1 commit into
open-telemetry:mainfrom
thswlsqls:fix/opentracing-shim-parent-context-baggage

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #7677

Description

  • When an OpenTracing span builder has an explicit parent (asChildOf / addReference), SpanBuilderShim.start() set the parent Context with only the wrapped parent Span, leaving out the baggage merged from the references.
  • As a result, the parentContext the SDK hands to Sampler.shouldSample and SpanProcessor.onStart never carried any baggage, even though the resulting SpanShim did.
  • This change computes the merged baggage first and puts it into the parent Context alongside the parent Span.
  • Matches what the module already does on the implicit-parent path (SpanShim.storeInContext adds span and baggage to the context) and in Propagation.injectTextMap.
  • The no-parent and implicit-parent branches, link handling, and the baggage passed to SpanShim are unchanged.
  • Related: OpenTracing Shim: Full multiple parent support. #4916 (introduced merging baggage from all references).

Testing done

  • Added SpanBuilderShimTest#baggage_explicitParent_inParentContext: a SpanProcessor captures Baggage.fromContext(parentContext) in onStart; with the fix reverted it fails with expected: "value1" but was: null, with the fix it passes.
  • ./gradlew :opentracing-shim:check — 85 tests passed.
  • SpanBuilderShim is package-private; no docs/apidiffs change.

@codecov

codecov Bot commented Sep 12, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.27%. Comparing base (77b1ac4) to head (df38090).

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8812      +/-   ##
============================================
- Coverage     91.28%   91.27%   -0.02%     
+ Complexity    10528    10526       -2     
============================================
  Files          1008     1008              
  Lines         28465    28466       +1     
  Branches       3617     3617              
============================================
- Hits          25984    25982       -2     
  Misses         1685     1685              
- Partials        796      799       +3     

☔ 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.

@opentelemetry-pr-dashboard

opentelemetry-pr-dashboard Bot commented Sep 12, 2026

Copy link
Copy Markdown

Pull request dashboard status

Waiting on reviewers · refreshed 2026-09-12 12:36 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.
  • Anything look wrong? Report it with what you expected; it helps us improve the dashboard.

@thswlsqls
thswlsqls marked this pull request as ready for review September 12, 2026 12:35
@thswlsqls
thswlsqls requested a review from a team as a code owner September 12, 2026 12:35
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.

Span baggage processor & no Baggage When Start

1 participant