Skip to content

feat: Implement strict trace continuation#2872

Merged
sl0thentr0py merged 4 commits intomasterfrom
feat/strict-trace-continuation
Mar 4, 2026
Merged

feat: Implement strict trace continuation#2872
sl0thentr0py merged 4 commits intomasterfrom
feat/strict-trace-continuation

Conversation

@giortzisg
Copy link
Contributor

Description

Implements the strict_trace_continuation feature for the Sentry Ruby SDK. This controls whether the SDK continues traces from unknown third-party services that happen to be instrumented by Sentry.

Changes

  • DSN org_id extraction: Parse org ID from the DSN host (e.g., o123.ingest.sentry.io -> "123") using the ORG_ID_REGEX pattern
  • org_id config option: An explicit setting that takes precedence over DSN parsing (useful for self-hosted/Relay setups)
  • strict_trace_continuation config option: Boolean, default false. Controls trace continuation behavior
  • Baggage propagation: Propagate org_id as sentry-org_id in outgoing baggage (both from PropagationContext and Transaction head baggage)
  • Incoming trace validation: Compare incoming sentry-org_id baggage against the SDK's own org ID per the decision matrix

Decision Matrix

Baggage org SDK org strict_trace_continuation Result
1 1 false Continue
None 1 false Continue
1 None false Continue
None None false Continue
1 2 false Start new
1 1 true Continue
None 1 true Start new
1 None true Start new
None None true Continue
1 2 true Start new

Files Modified

  • sentry-ruby/lib/sentry/dsn.rb - org_id extraction from DSN host
  • sentry-ruby/lib/sentry/configuration.rb - org_id, strict_trace_continuation, effective_org_id
  • sentry-ruby/lib/sentry/propagation_context.rb - should_continue_trace? validation + org_id in head baggage
  • sentry-ruby/lib/sentry/transaction.rb - org_id in head baggage
  • sentry-ruby/spec/sentry/dsn_spec.rb - Tests for org_id parsing and override
  • sentry-ruby/spec/sentry/propagation_context_spec.rb - Tests for full decision matrix

Reference Implementations

Closes #2865

🤖 Generated with Claude Code

@dingsdax dingsdax requested review from sl0thentr0py and solnic and removed request for sl0thentr0py February 27, 2026 11:56
giortzisg and others added 2 commits March 4, 2026 11:57
Add support for org_id extraction from DSN and strict trace continuation
to control whether the SDK continues traces from third-party services.

Changes:
- Extract org_id from DSN host (e.g., "o123.ingest.sentry.io" -> "123")
- Add `org_id` config option to explicitly set the organization ID
- Add `strict_trace_continuation` boolean config option (default: false)
- Propagate org_id in baggage as `sentry-org_id`
- Validate incoming trace org_id against SDK org_id per decision matrix
- Add comprehensive tests for all scenarios

Closes #2865

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The test DSN uses o447951.ingest.sentry.io, so the new org_id
propagation correctly adds sentry-org_id=447951 to baggage.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sl0thentr0py sl0thentr0py force-pushed the feat/strict-trace-continuation branch from 3f16ad3 to 5d40252 Compare March 4, 2026 10:57
@sl0thentr0py sl0thentr0py marked this pull request as ready for review March 4, 2026 11:52
Copy link

@cursor cursor bot left a comment

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.

Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

@sl0thentr0py sl0thentr0py merged commit cfcab4b into master Mar 4, 2026
258 of 259 checks passed
@sl0thentr0py sl0thentr0py deleted the feat/strict-trace-continuation branch March 4, 2026 12:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement strict trace continuation

3 participants