feat: Implement strict trace continuation#7705
Conversation
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. New Features ✨
Internal Changes 🔧Deps
🤖 This preview updates automatically when you update the PR. |
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #7705 +/- ##
=============================================
+ Coverage 85.401% 85.472% +0.070%
=============================================
Files 487 487
Lines 29086 29158 +72
Branches 12602 12625 +23
=============================================
+ Hits 24840 24922 +82
+ Misses 4196 4186 -10
Partials 50 50
... and 5 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
|
- Parse org_id from DSN host (e.g. `o123.ingest.sentry.io` → `123`) - Add `strictTraceContinuation` and `orgId` options to Options - Add `effectiveOrgId` computed property (explicit orgId > DSN > nil) - Propagate `sentry-org_id` in Baggage and TraceContext - Add `shouldContinueTrace` to SentryPropagationContext implementing the decision matrix for trace continuation validation Spec: https://develop.sentry.dev/sdk/foundations/trace-propagation/#strict-trace-continuation
ff9122b to
bdc33d9
Compare
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.
|
@antonis is this ready for review? |
|
Thank you for the ping @itaybre. Yes 😅 |
itaybre
left a comment
There was a problem hiding this comment.
LGTM, I just believe adding some notes regarding shouldContinueTrace will help future maintainers
Sentry Build Distribution
|
Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bc00c87 | 1214.34 ms | 1245.67 ms | 31.33 ms |
| b590539 | 1220.42 ms | 1239.82 ms | 19.40 ms |
| 3950d78 | 1212.52 ms | 1243.20 ms | 30.68 ms |
| a47ad66 | 1221.94 ms | 1249.59 ms | 27.66 ms |
| 1a887e2 | 1212.46 ms | 1241.33 ms | 28.87 ms |
| eaeb9bc | 1216.22 ms | 1250.78 ms | 34.56 ms |
| 554a67d | 1225.85 ms | 1254.71 ms | 28.86 ms |
| 6515f11 | 1214.72 ms | 1244.82 ms | 30.10 ms |
| d68691e | 1221.48 ms | 1248.13 ms | 26.65 ms |
| 21cd5ba | 1218.68 ms | 1255.54 ms | 36.86 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| bc00c87 | 24.14 KiB | 1.13 MiB | 1.10 MiB |
| b590539 | 24.14 KiB | 1.12 MiB | 1.09 MiB |
| 3950d78 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| a47ad66 | 24.14 KiB | 1.13 MiB | 1.10 MiB |
| 1a887e2 | 24.14 KiB | 1.09 MiB | 1.07 MiB |
| eaeb9bc | 24.14 KiB | 1.12 MiB | 1.10 MiB |
| 554a67d | 24.14 KiB | 1.13 MiB | 1.10 MiB |
| 6515f11 | 24.14 KiB | 1.11 MiB | 1.09 MiB |
| d68691e | 24.14 KiB | 1.12 MiB | 1.09 MiB |
| 21cd5ba | 24.14 KiB | 1.04 MiB | 1.02 MiB |

📜 Description
Implement Strict Trace Continuation.
org_idfrom DSN host (e.g.o123.ingest.sentry.io→"123")strictTraceContinuation(Bool) andorgId(String?) optionssentry-org_idin Baggage and TraceContextshouldContinueTrace(options:baggageOrgId:)implementing the decision matrix💡 Motivation and Context
Prevents cross-org trace continuation by validating org IDs in distributed traces.
Part of the Strict Trace Continuation initiative.
💚 How did you test it?
32 new unit tests covering DSN parsing, options resolution, decision matrix, baggage propagation, and trace context serialization.
📝 Checklist
sendDefaultPIIis enabled.