Draft
Conversation
Add org ID validation to distributed trace continuation to prevent traces from being continued across different Sentry organizations. - Parse org ID from DSN host (e.g., o1.ingest.us.sentry.io -> "1") - Add OrgId option to SentryOptions to override DSN-parsed value - Add StrictTraceContinuation bool option (default false) - Propagate sentry-org_id in outgoing baggage via DynamicSamplingContext - Validate org IDs in Hub.ContinueTrace: - Mismatched org IDs always start new trace (regardless of setting) - Missing incoming org_id + strict=true -> start new trace - Missing incoming org_id + strict=false -> continue trace (default) - Add comprehensive tests for all org ID validation scenarios - Update API approval snapshots Closes #4963 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
Semver Impact of This PR⚪ None (no version bump detected) 📋 Changelog PreviewThis is how your changes will appear in the changelog. Features ✨
Fixes 🐛
Dependencies ⬆️Deps
Other
🤖 This preview updates automatically when you update the PR. |
Contributor
|
…ion to CreateFromHeaders - Add CHANGELOG.md entry for strict trace continuation feature (#4981) - Fix CS8632 build error by adding #nullable enable before test methods using string? parameters in HubTests.cs - Add org ID mismatch validation directly in SentryPropagationContext.CreateFromHeaders so it starts a new trace when SDK and baggage org IDs don't match - Pass effective org ID from Hub.ContinueTrace to CreateFromHeaders - Add CreateFromHeaders_WithOrgMismatch_StartsNewTrace and CreateFromHeaders_WithOrgMatch_ContinuesTrace tests Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
3 tasks
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
Implements strict trace continuation to validate org IDs in distributed traces, preventing trace continuation from unknown third-party services.
org_idfrom DSN host (e.g.,o1inhttps://key@o1.ingest.us.sentry.io/123yields org ID"1")OrgIdconfig option to manually override DSN-parsed valueStrictTraceContinuationbool config option (defaultfalse)sentry-org_idin outgoing baggage viaDynamicSamplingContextHub.ContinueTrace():StrictTraceContinuation: true-> start new traceStrictTraceContinuation: false-> continue trace (default behavior)Changes
Source files:
src/Sentry/Dsn.cs- Parse org ID from DSN host subdomainsrc/Sentry/SentryOptions.cs- AddStrictTraceContinuationandOrgIdoptions,GetEffectiveOrgId()helpersrc/Sentry/DynamicSamplingContext.cs- Addorg_idto outgoing baggage in all DSC factory methodssrc/Sentry/Internal/Hub.cs- AddShouldContinueTrace()validation logic inContinueTrace()Test files:
test/Sentry.Tests/Protocol/DsnTests.cs- Tests for DSN org ID parsingtest/Sentry.Tests/HubTests.cs- Comprehensive[Theory]tests for all org ID validation scenariosSnapshot files:
OrgIdandStrictTraceContinuationpropertiesReferences
strictTraceContinuationsentry-javascript#16313Closes #4963