Skip to content

Internal - remove workaround, bug fixed in sdk v1.61.0.#480

Merged
cleverchuk merged 1 commit into
mainfrom
cc/NH-133021
May 4, 2026
Merged

Internal - remove workaround, bug fixed in sdk v1.61.0.#480
cleverchuk merged 1 commit into
mainfrom
cc/NH-133021

Conversation

@cleverchuk
Copy link
Copy Markdown
Contributor

Summary

Remove the PropagatedContext thread-local workaround now that the upstream OTel SDK bug is fixed in v1.61.0.

Details

The OTel SDK had a bug (open-telemetry/opentelemetry-java#8264) where it replaced the parent context with a primordial context for root spans. This caused XtraceOptions set during context propagation (extract) to be lost by the time the sampler ran (shouldSample).

The workaround used a ThreadLocal<XtraceOptions> as a side-channel: the propagator wrote to it during extract, and the sampler fell back to it when the context key lookup returned null. A try/finally in the sampler ensured the thread-local was always cleared.

With v1.61.0, the SDK correctly preserves the parent context for root spans. The standard propagation path — Context.with(TriggerTraceContextKey.KEY, ...) in extract, then parentContext.get(TriggerTraceContextKey.KEY) in shouldSample — now works as intended, making the thread-local redundant.

This commit:

  • Deletes the PropagatedContext thread-local helper
  • Removes the fallback read and try/finally cleanup in the sampler
  • Removes the PropagatedContext.set() call in the propagator
  • Removes the two tests that verified the workaround behavior

Test services data

  1. e-1712644058766987264
  2. e-1712643928659124224
  3. e-1742334541200846848
  4. e-1777406072376840192

Copilot AI review requested due to automatic review settings May 4, 2026 14:33
@cleverchuk cleverchuk requested review from a team as code owners May 4, 2026 14:33
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR removes the PropagatedContext thread-local workaround that previously compensated for an upstream OpenTelemetry SDK context-loss bug affecting root spans, now that the repository uses an SDK version where the issue is fixed.

Changes:

  • Deleted the PropagatedContext thread-local helper and removed all remaining usage.
  • Simplified SolarwindsSampler.shouldSample() to rely solely on TriggerTraceContextKey.KEY in the parent Context.
  • Removed tests that specifically validated the old thread-local fallback behavior.

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated no comments.

Show a summary per file
File Description
libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsSampler.java Removes the PropagatedContext fallback/cleanup and simplifies sampling flow to use the propagated Context key only.
libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/SolarwindsContextPropagator.java Stops populating the removed thread-local side-channel during extract().
libs/shared/src/main/java/com/solarwinds/opentelemetry/extensions/PropagatedContext.java Deletes the thread-local workaround helper entirely.
libs/shared/src/test/java/com/solarwinds/opentelemetry/extensions/SolarwindsSamplerTest.java Removes a test that asserted the sampler’s thread-local fallback behavior for root spans.
libs/shared/src/test/java/com/solarwinds/opentelemetry/extensions/SolarwindsContextPropagatorTest.java Removes a test that asserted extract() populates the thread-local workaround.

Copy link
Copy Markdown

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Copy link
Copy Markdown

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Copy link
Copy Markdown

@tammy-baylis-swi tammy-baylis-swi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great

Copy link
Copy Markdown

@jerrytfleung jerrytfleung left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@cleverchuk cleverchuk merged commit 64610d6 into main May 4, 2026
20 checks passed
@cleverchuk cleverchuk deleted the cc/NH-133021 branch May 4, 2026 18:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

4 participants