Repository navigation
feat: add sentry_continue_trace - #2237
Merged
jpnurmi merged 4 commits intoOct 26, 2026
Merged
Conversation
Add `sentry_continue_trace()`, `sentry_scope_continue_trace()` and their `_n` variants to continue a trace from incoming `sentry-trace` and `baggage` headers without starting a transaction, as required by the trace propagation spec's `continueTrace`. The headers are parsed with the same code as `sentry_transaction_context_update_from_header()`. When strict trace continuation allows it, the scope's propagation context takes the incoming trace and parent span IDs, sampling decision and `sample_rand`, and the incoming baggage is frozen as the DSC. Otherwise, a new trace is started. Like with `sentry_set_trace()`, transactions no longer act as trace boundaries afterwards. Per the spec, a missing `sentry-sample_rand` is derived from the incoming `sample_rate` and sampling decision, transactions started afterwards inherit the sampling decision, and the DSC of error events reports it instead of recomputing `sampled` from the local sample rate.
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## jpnurmi/feat/scope-set-trace #2237 +/- ##
================================================================
+ Coverage 76.18% 76.27% +0.08%
================================================================
Files 104 104
Lines 29584 29694 +110
Branches 5480 5500 +20
================================================================
+ Hits 22540 22649 +109
+ Misses 5674 5663 -11
- Partials 1370 1382 +12 🚀 New features to boost your workflow:
|
limbonaut
reviewed
Oct 23, 2026
mujacica
approved these changes
Oct 23, 2026
`sentry_scope_continue_trace()` looked up the global options, which are not installed yet while `sentry_init()` runs the initial scope callback, so a trace continued from there was dropped. Take the options from the scope chain instead, where the isolation scope carries them already, and do the same in `sentry_scope_set_trace()`. Also build the default DSC before running the initial scope callback, so that it no longer overwrites a DSC frozen from incoming baggage.
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.
Want reviews to match your repository better? Bugbot Learning can learn team-specific rules from PR activity. A team admin can enable Learning in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 27ac193. Configure here.
A clone of the isolation scope has neither its own options nor a parent that carries them, so `ref_options()` found none, which made `sentry_scope_continue_trace()` a no-op on it and left the DSC stale in `sentry_scope_set_trace()`. Fall back to the global options when the scope chain carries none.
limbonaut
approved these changes
Oct 26, 2026
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.

Add
sentry_continue_trace(),sentry_scope_continue_trace()and their_nvariants to continue a trace from incomingsentry-traceandbaggageheaders without starting a transaction, as required by the trace propagation spec'scontinueTrace.The headers are parsed with the same code as
sentry_transaction_context_update_from_header(). When strict trace continuation allows it, the scope's propagation context takes the incoming trace and parent span IDs, sampling decision andsample_rand, and the incoming baggage is frozen as the DSC. Otherwise, a new trace is started. Like withsentry_set_trace(), transactions no longer act as trace boundaries afterwards.Per the spec, a missing
sentry-sample_randis derived from the incomingsample_rateand sampling decision, transactions started afterwards inherit the sampling decision, and the DSC of error events reports it instead of recomputingsampledfrom the local sample rate.Ref: