ref: Decouple propagator from span processor#1223
Conversation
Semver Impact of This PR🟢 Patch (bug fixes) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Bug Fixes 🐛
Internal Changes 🔧Ai
Deps
Other
🤖 This preview updates automatically when you update the PR. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
| // freeze it for the transaction itself. | ||
| txn.SetDynamicSamplingContext(dsc) | ||
| return dsc, true | ||
| } |
There was a problem hiding this comment.
GetDSC overwrites frozen upstream DSC with local values
High Severity
GetDSC unconditionally calls DynamicSamplingContextFromTransaction(txn) which recomputes the DSC from the local transaction's fields, then overwrites the transaction's DSC via SetDynamicSamplingContext. This ignores any already-frozen upstream DSC that was set on the transaction by the span processor during OnStart. The old ToBaggage() method checked !s.dynamicSamplingContext.IsFrozen() before recomputing, preserving upstream-propagated DSC entries (like the originating service's public_key, release, environment). The new code always replaces those with locally-computed values, breaking DSC propagation in distributed traces.


Description
This changes the current behavior of the sentry otel propagator to work without needing the span processor. The change is influenced by the otlp integration also needing a propagator, and since it doesn't make sense to couple the otlp integration with the span_map, this extracts and refines the propagator functionality to:
WithDSCSourceto override fetching the dynamic sampling context. When using alongside span processor the propagator should inject the span map, so that it can fetch the DSC from the span itself.The PR also moves the propagator under
otel/internal/commonso that it can be re-used by the PR that will implement the otlp integration underotel/otlp.Note
Tried to split the changes into first refactoring the propagator.go in-place and then move it under
common, but the diff still shows it as a separate file. For easier review, it's probably better to have a look at the individual commits.Issues
Changelog Entry Instructions
To add a custom changelog entry, uncomment the section above. Supports:
For more details: custom changelog entries
Reminders
feat:,fix:,ref:,meta:)