Internal - remove workaround, bug fixed in sdk v1.61.0.#480
Merged
Conversation
Contributor
There was a problem hiding this comment.
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
PropagatedContextthread-local helper and removed all remaining usage. - Simplified
SolarwindsSampler.shouldSample()to rely solely onTriggerTraceContextKey.KEYin the parentContext. - 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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Remove the
PropagatedContextthread-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
XtraceOptionsset 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 duringextract, and the sampler fell back to it when the context key lookup returned null. Atry/finallyin 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, ...)inextract, thenparentContext.get(TriggerTraceContextKey.KEY)inshouldSample— now works as intended, making the thread-local redundant.This commit:
PropagatedContextthread-local helpertry/finallycleanup in the samplerPropagatedContext.set()call in the propagatorTest services data