Skip to content

feat: Implement strict trace continuation#7705

Open
antonis wants to merge 9 commits intomainfrom
feat/strict-trace-continuation
Open

feat: Implement strict trace continuation#7705
antonis wants to merge 9 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
  • Add per-call attachAllThreads override by itaybre in #7767
  • Add attachAllThreads option by itaybre in #7764

Bug Fixes 🐛

  • Move SessionTracker file I/O off the main thread by denrase in #7704
  • Copy incoming tags dict to prevent crash by itaybre in #7763
  • Per-instance unmaskView propagates to child views by denrase in #7733

Documentation 📚

  • Add SentryCrash analysis and improvement plan document by itaybre in #7528

Internal Changes 🔧

Deps

  • Bump ruby/setup-ruby from 1.295.0 to 1.298.0 by dependabot in #7751
  • Bump codecov/codecov-action from 5.5.3 to 6.0.0 by dependabot in #7749
  • Bump getsentry/craft from 2.25.0 to 2.25.2 by dependabot in #7748
  • Bump fastlane-plugin-sentry from 2.4.0 to 2.5.0 by dependabot in #7746
  • Bump actions/deploy-pages from 4.0.5 to 5.0.0 by dependabot in #7747
  • Update clang-format version by sentry-mobile-updater in #7755
  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.25.0 to 2.25.2 by dependabot in #7750
  • Bump activesupport from 7.2.3 to 7.2.3.1 by dependabot in #7732
  • Bump fastlane-plugin-sentry from 2.3.0 to 2.4.0 by dependabot in #7724
  • Bump ruby/setup-ruby from 1.292.0 to 1.295.0 by dependabot in #7728
  • Bump getsentry/craft from 2.24.1 to 2.25.0 by dependabot in #7729
  • Bump codecov/codecov-action from 5.5.2 to 5.5.3 by dependabot in #7725
  • Bump actions/create-github-app-token from 2.2.1 to 3.0.0 by dependabot in #7726
  • Bump getsentry/craft/.github/workflows/changelog-preview.yml from 2.24.1 to 2.25.0 by dependabot in #7727
  • Bump json from 2.18.1 to 2.19.2 by dependabot in #7709

Other

  • Update validate-pr workflow by stephanie-anderson in #7769
  • Pin GitHub Actions to full-length commit SHAs by joshuarli in #7730

Other

  • impr: Align app lifecycle breadcrumb states with app context by denrase in #7703

🤖 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 addeee2

@codecov
Copy link
Copy Markdown

codecov bot commented Mar 17, 2026

Codecov Report

❌ Patch coverage is 98.71795% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 85.149%. Comparing base (2b71685) to head (addeee2).
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
Sources/Sentry/SentryOptionsInternal.m 75.000% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@              Coverage Diff              @@
##              main     #7705       +/-   ##
=============================================
- Coverage   85.412%   85.149%   -0.263%     
=============================================
  Files          487       487               
  Lines        29086     29158       +72     
  Branches     12592     12605       +13     
=============================================
- Hits         24843     24828       -15     
- Misses        4193      4278       +85     
- Partials        50        52        +2     
Files with missing lines Coverage Δ
Sources/Sentry/SentryBaggage.m 100.000% <100.000%> (ø)
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%> (ø)
Sources/Sentry/SentryOptionsInternal.m 98.979% <75.000%> (-0.500%) ⬇️

... and 15 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 2b71685...addeee2. 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 😅

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.

2 participants