Skip to content

feat: add sentry_continue_trace - #2237

Merged
jpnurmi merged 4 commits into
jpnurmi/feat/scope-set-tracefrom
jpnurmi/feat/continue-trace
Oct 26, 2026
Merged

jpnurmi merged 4 commits into
jpnurmi/feat/scope-set-tracefrom
jpnurmi/feat/continue-trace

Conversation

@jpnurmi

@jpnurmi jpnurmi commented Oct 23, 2026

Copy link
Copy Markdown
Collaborator

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.

Ref:

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.
@github-actions

github-actions Bot commented Oct 23, 2026 •

Copy link
Copy Markdown
Messages
📖 Do not forget to update Sentry-docs with your feature once the pull request gets approved.

Generated by 🚫 dangerJS against d8c7479

@jpnurmi
jpnurmi added this pull request to stack #2238 October 23, 2026 08:57
@jpnurmi jpnurmi added the v1 Targets 1.0 (v1 branch) label Oct 23, 2026
@codecov

codecov Bot commented Oct 23, 2026 •

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 98.29060% with 2 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.27%. Comparing base (ab61016) to head (d8c7479).

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:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Comment thread src/sentry_scope.c Resolved
`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.

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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

Comment thread src/sentry_scope.c Resolved
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.
@jpnurmi
jpnurmi merged commit d9c645c into v1 Oct 26, 2026
64 of 67 checks passed
@jpnurmi
jpnurmi deleted the jpnurmi/feat/continue-trace branch October 26, 2026 12:07
@jpnurmi jpnurmi linked an issue Oct 26, 2026 that may be closed by this pull request
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

v1 Targets 1.0 (v1 branch)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Align and flesh out trace propagation API

3 participants