Skip to content

feat: Implement strict trace continuation#7705

Merged
antonis merged 13 commits intomainfrom
feat/strict-trace-continuation
Apr 8, 2026
Merged

feat: Implement strict trace continuation#7705
antonis merged 13 commits intomainfrom
feat/strict-trace-continuation

Conversation

@antonis
Copy link
Copy Markdown
Contributor

@antonis antonis commented Mar 17, 2026

📜 Description

Implement Strict Trace Continuation.

  • Parse org_id from DSN host (e.g. o123.ingest.sentry.io"123")
  • Add strictTraceContinuation (Bool) and orgId (String?) options
  • Propagate sentry-org_id in Baggage and TraceContext
  • Add shouldContinueTrace(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

  • I added tests to verify the changes.
  • No new PII added or SDK only sends newly added PII if sendDefaultPII is enabled.
  • I updated the docs if needed. Docs PR: docs: Add strict trace continuation for Apple sentry-docs#17140
  • I updated the wizard if needed.
  • Review from the native team if needed.
  • No breaking change or entry added to the changelog.
  • No breaking change for hybrid SDKs or communicated to hybrid SDKs.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

Semver Impact of This PR

🟡 Minor (new features)

📋 Changelog Preview

This is how your changes will appear in the changelog.
Entries from this PR are highlighted with a left border (blockquote style).


New Features ✨

  • Implement strict trace continuation by antonis in #7705

Internal Changes 🔧

Deps

  • Bump mikepenz/action-junit-report from 6.3.1 to 6.4.0 by dependabot in #7773
  • Bump ruby/setup-ruby from 1.298.0 to 1.299.0 by dependabot in #7772
  • Bump fastlane-plugin-sentry from 2.5.0 to 2.5.1 by dependabot in #7771

🤖 This preview updates automatically when you update the PR.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

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

Generated by 🚫 dangerJS against 0da8c03

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 85.472%. Comparing base (a47ad66) to head (0da8c03).
⚠️ Report is 1 commits behind head on main.
✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@              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               
Files with missing lines Coverage Δ
Sources/Sentry/SentryBaggage.m 100.000% <100.000%> (ø)
Sources/Sentry/SentryOptionsInternal.m 99.489% <100.000%> (+0.010%) ⬆️
Sources/Sentry/SentryTraceContext.m 96.666% <100.000%> (+0.588%) ⬆️
Sources/Swift/Options.swift 100.000% <100.000%> (ø)
Sources/Swift/SentryDsn.swift 93.000% <100.000%> (+0.526%) ⬆️
Sources/Swift/State/SentryPropagationContext.swift 100.000% <100.000%> (ø)

... and 5 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update a47ad66...0da8c03. Read the comment docs.

- 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
Copy link
Copy Markdown

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

Fix All in Cursor

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

@antonis antonis marked this pull request as ready for review March 27, 2026 09:30
@itaybre
Copy link
Copy Markdown
Contributor

itaybre commented Apr 1, 2026

@antonis is this ready for review?

@antonis
Copy link
Copy Markdown
Contributor Author

antonis commented Apr 2, 2026

Thank you for the ping @itaybre. Yes 😅

@itaybre itaybre added the ready-to-merge Use this label to trigger all PR workflows label Apr 7, 2026
Copy link
Copy Markdown
Contributor

@itaybre itaybre left a comment

Choose a reason for hiding this comment

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

LGTM, I just believe adding some notes regarding shouldContinueTrace will help future maintainers

@sentry
Copy link
Copy Markdown

sentry bot commented Apr 7, 2026

Sentry Build Distribution

App Name App ID Version Configuration Install Page
SDK-Size io.sentry.sample.SDK-Size 9.9.0 (1) Release Install Build

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 7, 2026

Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1223.48 ms 1262.45 ms 38.97 ms
Size 24.14 KiB 1.13 MiB 1.11 MiB

Baseline results on branch: main

Startup times

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

Previous results on branch: feat/strict-trace-continuation

Startup times

Revision Plain With Sentry Diff
b283ab8 1217.55 ms 1259.67 ms 42.12 ms

App size

Revision Plain With Sentry Diff
b283ab8 24.14 KiB 1.13 MiB 1.11 MiB

@antonis antonis merged commit 4c2c80d into main Apr 8, 2026
208 checks passed
@antonis antonis deleted the feat/strict-trace-continuation branch April 8, 2026 09:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-to-merge Use this label to trigger all PR workflows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants