Skip to content

feat: Implement strict trace continuation#3567

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

feat: Implement strict trace continuation#3567
antonis wants to merge 21 commits intomainfrom
feat/strict-trace-continuation

Conversation

@antonis
Copy link
Copy Markdown

@antonis antonis commented Mar 17, 2026

📜 Description

Implement Strict Trace Continuation in the Dart SDK.

  • Add strictTraceContinuation (bool) and orgId (String?) options on SentryOptions
  • Extract org_id from DSN host; effectiveOrgId prefers explicit over DSN (trims whitespace)
  • Propagate sentry-org_id in baggage and trace context header
  • Validate incoming traces in SentryTransactionContext.fromSentryTrace per the spec decision matrix
  • Pass options through to the native Android SDK on init

💡 Motivation and Context

Prevents cross-organization trace continuation by validating org IDs in distributed traces.

Part of the Strict Trace Continuation initiative.

Platform coverage

Platform Coverage
Dart Full
Android Full — via sentry-android 8.39.1 (sentry-java#5136)
iOS Dart layer only — native support requires Sentry Cocoa v9 (#7705); Flutter is pinned to Sentry/HybridSDK 8.x

💚 How did you test it?

46 new unit tests covering DSN parsing, option resolution, decision matrix, baggage/header propagation, and fromSentryTrace validation.

📝 Checklist

  • I reviewed submitted code
  • I added tests to verify changes
  • No new PII added or SDK only sends newly added PII if sendDefaultPii is enabled
  • I updated the docs if needed
  • All tests passing
  • No breaking changes

🔮 Next steps

- Parse org_id from DSN host (e.g. `o123.ingest.sentry.io` → `123`)
- Add `strictTraceContinuation` and `orgId` options to SentryOptions
- Propagate `sentry-org_id` in baggage/DSC
- Validate incoming traces: mismatched org IDs start a new trace;
  strict mode also rejects traces with missing org IDs

Spec: https://develop.sentry.dev/sdk/foundations/trace-propagation/#strict-trace-continuation

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@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 e3d200a

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 17, 2026

iOS Performance metrics 🚀

  Plain With Sentry Diff
Startup time 1254.05 ms 1256.48 ms 2.43 ms
Size 5.73 MiB 6.18 MiB 464.41 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
c8596a6 1234.11 ms 1241.19 ms 7.08 ms
57eccdf 1247.91 ms 1252.76 ms 4.84 ms
d789735 1240.58 ms 1246.41 ms 5.82 ms
396cb30 1265.06 ms 1265.73 ms 0.67 ms
3615e19 1225.02 ms 1234.57 ms 9.55 ms
1fff351 1265.77 ms 1256.06 ms -9.70 ms
cdf371b 1246.24 ms 1251.10 ms 4.86 ms
5f4cc67 1236.77 ms 1237.94 ms 1.17 ms
d5a1225 1252.46 ms 1254.66 ms 2.20 ms
73a3c38 1263.37 ms 1277.90 ms 14.53 ms

App size

Revision Plain With Sentry Diff
c8596a6 7.86 MiB 9.44 MiB 1.58 MiB
57eccdf 5.73 MiB 6.17 MiB 453.80 KiB
d789735 5.53 MiB 5.96 MiB 443.28 KiB
396cb30 5.53 MiB 6.01 MiB 488.17 KiB
3615e19 7.86 MiB 9.44 MiB 1.58 MiB
1fff351 5.73 MiB 6.17 MiB 455.43 KiB
cdf371b 5.53 MiB 6.02 MiB 501.23 KiB
5f4cc67 5.73 MiB 6.17 MiB 455.49 KiB
d5a1225 5.73 MiB 6.17 MiB 453.73 KiB
73a3c38 7.86 MiB 9.44 MiB 1.58 MiB

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

Startup times

Revision Plain With Sentry Diff
25b589e 1265.35 ms 1262.23 ms -3.12 ms
a48e7d7 1239.53 ms 1238.38 ms -1.16 ms
a1d3441 1224.39 ms 1229.85 ms 5.46 ms
223b1b3 1242.87 ms 1250.09 ms 7.21 ms
7c249a7 1234.02 ms 1237.81 ms 3.79 ms
4afe986 1264.88 ms 1255.48 ms -9.41 ms
80a6525 1251.04 ms 1249.98 ms -1.06 ms
f96a725 1263.67 ms 1268.90 ms 5.22 ms
e3d200a 1251.73 ms 1257.06 ms 5.33 ms
9c81fe0 1253.11 ms 1254.57 ms 1.46 ms

App size

Revision Plain With Sentry Diff
25b589e 5.73 MiB 6.18 MiB 464.45 KiB
a48e7d7 5.73 MiB 6.17 MiB 456.50 KiB
a1d3441 5.73 MiB 6.18 MiB 464.46 KiB
223b1b3 5.73 MiB 6.18 MiB 464.42 KiB
7c249a7 5.73 MiB 6.17 MiB 456.52 KiB
4afe986 5.73 MiB 6.18 MiB 464.46 KiB
80a6525 5.73 MiB 6.17 MiB 456.50 KiB
f96a725 5.73 MiB 6.17 MiB 456.50 KiB
e3d200a 5.73 MiB 6.17 MiB 456.50 KiB
9c81fe0 5.73 MiB 6.18 MiB 464.45 KiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Mar 17, 2026

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 367.13 ms 350.35 ms -16.78 ms
Size 14.31 MiB 15.62 MiB 1.31 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
79f6b41 469.66 ms 525.90 ms 56.24 ms
d5a1225 377.37 ms 366.56 ms -10.81 ms
0fb3800 465.64 ms 536.77 ms 71.13 ms
e04b24b 504.72 ms 516.43 ms 11.71 ms
584a4b7 367.74 ms 353.83 ms -13.91 ms
3801d52 397.53 ms 378.87 ms -18.66 ms
396cb30 405.70 ms 427.56 ms 21.86 ms
7cfbbd6 499.69 ms 592.24 ms 92.55 ms
e200a70 433.06 ms 437.00 ms 3.94 ms
d789735 363.95 ms 358.09 ms -5.87 ms

App size

Revision Plain With Sentry Diff
79f6b41 6.54 MiB 7.69 MiB 1.15 MiB
d5a1225 14.31 MiB 15.49 MiB 1.19 MiB
0fb3800 6.54 MiB 7.69 MiB 1.15 MiB
e04b24b 13.93 MiB 15.00 MiB 1.06 MiB
584a4b7 14.09 MiB 15.28 MiB 1.19 MiB
3801d52 14.31 MiB 15.49 MiB 1.19 MiB
396cb30 13.93 MiB 15.06 MiB 1.13 MiB
7cfbbd6 6.54 MiB 7.70 MiB 1.17 MiB
e200a70 13.93 MiB 15.18 MiB 1.25 MiB
d789735 13.93 MiB 15.18 MiB 1.25 MiB

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

Startup times

Revision Plain With Sentry Diff
80a6525 386.66 ms 386.65 ms -0.01 ms
f96a725 411.33 ms 420.06 ms 8.73 ms
c78ff38 433.65 ms 433.69 ms 0.03 ms
e3d200a 421.91 ms 432.42 ms 10.51 ms
9c81fe0 378.11 ms 382.77 ms 4.65 ms
4afe986 385.21 ms 380.48 ms -4.73 ms
7c249a7 366.72 ms 369.06 ms 2.34 ms
e3bfa44 390.52 ms 373.63 ms -16.89 ms
a48e7d7 371.18 ms 361.09 ms -10.09 ms
25b589e 437.27 ms 466.53 ms 29.26 ms

App size

Revision Plain With Sentry Diff
80a6525 14.31 MiB 15.49 MiB 1.19 MiB
f96a725 14.31 MiB 15.49 MiB 1.19 MiB
c78ff38 14.31 MiB 15.49 MiB 1.19 MiB
e3d200a 14.31 MiB 15.49 MiB 1.19 MiB
9c81fe0 14.31 MiB 15.62 MiB 1.31 MiB
4afe986 14.31 MiB 15.62 MiB 1.31 MiB
7c249a7 14.31 MiB 15.49 MiB 1.19 MiB
e3bfa44 14.31 MiB 15.49 MiB 1.19 MiB
a48e7d7 14.31 MiB 15.49 MiB 1.19 MiB
25b589e 14.31 MiB 15.62 MiB 1.31 MiB

Copy link
Copy Markdown
Author

@antonis antonis left a comment

Choose a reason for hiding this comment

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

@buenaflor heads up that this is a fully AI generated implementation of the Strict Trace Continuation feature using the feature implementation skill

@antonis antonis marked this pull request as ready for review March 17, 2026 15:28
Comment thread packages/dart/lib/src/protocol/dsn.dart
Comment thread packages/dart/lib/src/utils/tracing_utils.dart Outdated
@antonis antonis marked this pull request as draft March 26, 2026 14:29
Copy link
Copy Markdown
Author

@antonis antonis left a comment

Choose a reason for hiding this comment

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

Moving this back to draft to also handle the Android/iOS native dependencies.

@github-actions
Copy link
Copy Markdown
Contributor

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


Features

  • Implement strict trace continuation by antonis in #3567

Internal Changes

  • Add dep update pattern to Dependencies changelog category by buenaflor in #3642
  • Replace Danger with release.yml changelog policy by buenaflor in #3641

🤖 This preview updates automatically when you update the PR.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 16, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.82%. Comparing base (f7e0e8b) to head (d80a407).
✅ All tests successful. No failed tests found.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3567      +/-   ##
==========================================
+ Coverage   86.78%   86.82%   +0.03%     
==========================================
  Files         335      335              
  Lines       11934    11968      +34     
==========================================
+ Hits        10357    10391      +34     
  Misses       1577     1577              
Flag Coverage Δ
sentry 86.70% <100.00%> (+0.07%) ⬆️
sentry_dio 97.73% <ø> (ø)
sentry_drift 93.57% <ø> (ø)
sentry_file 65.29% <ø> (ø)
sentry_firebase_remote_config 100.00% <ø> (ø)
sentry_flutter 91.17% <ø> (ø)
sentry_hive 77.48% <ø> (ø)
sentry_isar 74.37% <ø> (ø)
sentry_link 21.50% <ø> (ø)
sentry_logging 97.01% <ø> (ø)
sentry_sqflite 88.81% <ø> (ø)
sentry_supabase 97.27% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@antonis
Copy link
Copy Markdown
Author

antonis commented Apr 16, 2026

Status update: Merged latest main and moved changelog to Unreleased.

The Dart-layer implementation is self-contained and fully functional — trace propagation, org ID validation, and the decision matrix all work in pure Dart code.

To deliver the full functionality, the native SDK dependencies need to be bumped so that native-originated trace contexts also include org_id:

@sentry
Copy link
Copy Markdown

sentry Bot commented Apr 16, 2026

📲 Install Builds

Android

🔗 App Name App ID Version Configuration
sentry_flutter_example io.sentry.flutter.sample 9.19.0 (1) Release

⚙️ sentry-flutter Build Distribution Settings

@buenaflor
Copy link
Copy Markdown
Contributor

@antonis I am not sure whether a backport is planned for v8 cocoa, so this feature may be blocked for now or we compromise and say that cocoa compatibility is limited for now

@antonis
Copy link
Copy Markdown
Author

antonis commented Apr 17, 2026

we compromise and say that cocoa compatibility is limited for now

Sounds good @buenaflor 👍 I'll proceed with that and open an issue to follow up when Cocoa is bumped

Comment thread packages/flutter/lib/src/native/java/sentry_native_java_init.dart Outdated
Comment thread packages/dart/lib/src/sentry_trace_context_header.dart
binarySizeTest:
diffMin: 900 KiB
diffMax: 1300 KiB
diffMax: 1350 KiB
Copy link
Copy Markdown
Author

@antonis antonis Apr 22, 2026

Choose a reason for hiding this comment

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

The changes led to ~1345 KiB, exceeding the 1300 KiB threshold

@antonis
Copy link
Copy Markdown
Author

antonis commented Apr 22, 2026

@sentry review

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.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit 223b1b3. Configure here.

@antonis
Copy link
Copy Markdown
Author

antonis commented Apr 22, 2026

we compromise and say that cocoa compatibility is limited for now

Sounds good @buenaflor 👍 I'll proceed with that and open an issue to follow up when Cocoa is bumped

This is now ready for another round 🙇

@antonis antonis marked this pull request as ready for review April 22, 2026 16:57
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