Skip to content

Return null from TracerShim extract when the carrier has no span context - #8505

Merged
jack-berg merged 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/tracershim-extract-empty-carrier-null
Jul 13, 2026
Merged

Return null from TracerShim extract when the carrier has no span context#8505
jack-berg merged 2 commits into
open-telemetry:mainfrom
thswlsqls:fix/tracershim-extract-empty-carrier-null

Conversation

@thswlsqls

Copy link
Copy Markdown
Contributor

Fixes #4344

Description

  • Propagation.extractTextMap used Context.current() as the extract parent. A TextMapPropagator returns the input context unchanged when the carrier has no valid headers, so an empty-carrier extract with an active span returned that span as a non-null SpanContextShim.
  • This violates the OpenTracing Tracer#extract contract: with no serialized span state in the carrier, the result must be null.
  • Switching the parent to Context.root() makes extraction depend only on the carrier. A populated carrier decodes exactly as before; inject is left unchanged (preserving the current context there is intended).
  • The shim is deprecated but still published, so fixing this contract violation is still worthwhile.

Testing done

  • Added TracerShimTest#extract_emptyCarrier_withActiveSpan_returnsNull (fails before the change, passes after).
  • ./gradlew :opentracing-shim:check — 83 tests passed.
  • Added a ## Unreleased ### Shims entry in CHANGELOG.md. No public API change (apidiff unaffected; Propagation/TracerShim are package-private).

@thswlsqls
thswlsqls force-pushed the fix/tracershim-extract-empty-carrier-null branch from 104cdd4 to 2c22bed Compare June 22, 2026 08:03
@codecov

codecov Bot commented Jun 22, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.61%. Comparing base (c5c9d87) to head (fea6e51).
⚠️ Report is 2 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #8505      +/-   ##
============================================
+ Coverage     91.60%   91.61%   +0.01%     
- Complexity    10312    10314       +2     
============================================
  Files          1013     1013              
  Lines         27274    27274              
  Branches       3202     3202              
============================================
+ Hits          24983    24986       +3     
+ Misses         1563     1562       -1     
+ Partials        728      726       -2     

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

@jack-berg jack-berg added the needs author feedback Waiting for additional feedback from the author label Jul 2, 2026
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

This has been automatically marked as stale because it has been marked as needing author feedback and has not had any activity for 7 days. It will be closed if no further activity occurs within 7 days of this comment.

@github-actions github-actions Bot added the Stale label Jul 9, 2026
@jack-berg
jack-berg marked this pull request as ready for review July 13, 2026 20:25
@jack-berg
jack-berg requested a review from a team as a code owner July 13, 2026 20:25
@github-actions github-actions Bot removed the Stale label Jul 13, 2026
@jack-berg
jack-berg merged commit fa254e7 into open-telemetry:main Jul 13, 2026
29 checks passed
@otelbot

otelbot Bot commented Jul 13, 2026

Copy link
Copy Markdown
Contributor

Thank you for your contribution @thswlsqls! 🎉 We would like to hear from you about your experience contributing to OpenTelemetry by taking a few minutes to fill out this survey.

@thswlsqls
thswlsqls deleted the fix/tracershim-extract-empty-carrier-null branch July 17, 2026 02:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs author feedback Waiting for additional feedback from the author

Projects

None yet

Development

Successfully merging this pull request may close these issues.

TracerShim#extract() returning current context instead of null in case of empty carrier

2 participants