Skip to content

feat: Implement strict trace continuation#3567

Draft
antonis wants to merge 10 commits intomainfrom
feat/strict-trace-continuation
Draft

feat: Implement strict trace continuation#3567
antonis wants to merge 10 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.

Changes:

  • dsn.dart — Extract org_id from DSN host using ^o(\d+)\. regex
  • sentry_options.dart — Add strictTraceContinuation (bool), orgId (String?), and effectiveOrgId getter
  • sentry_baggage.dart — Add sentry-org_id get/set, propagate in setValuesFromScope
  • sentry_trace_context_header.dart — Add orgId field, propagate through JSON/baggage serialization
  • sentry_tracer.dart — Include org_id when creating trace context headers
  • tracing_utils.dart — Add shouldContinueTrace() implementing the decision matrix
  • sentry_transaction_context.dart — Validate org ID in fromSentryTrace, start new trace on mismatch
  • New test file with comprehensive coverage of all scenarios

💡 Motivation and Context

Prevents cross-organization trace continuation by validating org IDs in distributed traces. When org IDs don't match, the SDK starts a fresh trace instead of continuing the foreign one.

Part of the Strict Trace Continuation initiative.

💚 How did you test it?

  • Added comprehensive test suite (strict_trace_continuation_test.dart) covering:
    • DSN org ID extraction (7 cases)
    • SentryOptions effective org ID resolution (4 cases)
    • Decision matrix for shouldContinueTrace (9 cases)
    • Baggage org_id propagation (5 cases)
    • TraceContextHeader serialization (5 cases)
    • SentryTransactionContext.fromSentryTrace validation (5 cases)

📝 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 1245.18 ms 1250.85 ms 5.67 ms
Size 5.73 MiB 6.18 MiB 456.84 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
55b7a00 1279.45 ms 1274.58 ms -4.87 ms
0fb45d0 1273.24 ms 1286.44 ms 13.19 ms
e0c8591 1259.85 ms 1257.31 ms -2.54 ms
f3771ea 1258.53 ms 1255.22 ms -3.32 ms
f761369 1261.69 ms 1277.82 ms 16.12 ms
fec56a1 1251.71 ms 1241.31 ms -10.40 ms
af96ef2 1260.79 ms 1259.61 ms -1.17 ms
b4b7781 1239.98 ms 1245.67 ms 5.69 ms
c26ed0a 1244.11 ms 1263.85 ms 19.75 ms
c8596a6 1234.11 ms 1241.19 ms 7.08 ms

App size

Revision Plain With Sentry Diff
55b7a00 5.73 MiB 6.17 MiB 453.79 KiB
0fb45d0 7.86 MiB 9.44 MiB 1.58 MiB
e0c8591 5.53 MiB 5.96 MiB 444.86 KiB
f3771ea 5.73 MiB 6.17 MiB 455.44 KiB
f761369 7.86 MiB 9.44 MiB 1.58 MiB
fec56a1 5.73 MiB 6.17 MiB 455.53 KiB
af96ef2 5.53 MiB 6.02 MiB 501.31 KiB
b4b7781 5.73 MiB 6.17 MiB 455.48 KiB
c26ed0a 5.53 MiB 5.97 MiB 453.76 KiB
c8596a6 7.86 MiB 9.44 MiB 1.58 MiB

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

Startup times

Revision Plain With Sentry Diff
7c249a7 1234.02 ms 1237.81 ms 3.79 ms
80a6525 1251.04 ms 1249.98 ms -1.06 ms
f96a725 1263.67 ms 1268.90 ms 5.22 ms
a48e7d7 1239.53 ms 1238.38 ms -1.16 ms
e3bfa44 1238.25 ms 1234.53 ms -3.72 ms
e3d200a 1251.73 ms 1257.06 ms 5.33 ms

App size

Revision Plain With Sentry Diff
7c249a7 5.73 MiB 6.17 MiB 456.52 KiB
80a6525 5.73 MiB 6.17 MiB 456.50 KiB
f96a725 5.73 MiB 6.17 MiB 456.50 KiB
a48e7d7 5.73 MiB 6.17 MiB 456.50 KiB
e3bfa44 5.73 MiB 6.17 MiB 456.50 KiB
e3d200a 5.73 MiB 6.17 MiB 456.50 KiB

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 17, 2026

Android Performance metrics 🚀

  Plain With Sentry Diff
Startup time 433.65 ms 433.69 ms 0.03 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
4298701 524.40 ms 633.30 ms 108.90 ms
e200a70 433.06 ms 437.00 ms 3.94 ms
ec78888 457.94 ms 519.96 ms 62.02 ms
af96ef2 375.84 ms 382.02 ms 6.18 ms
79f6b41 469.66 ms 525.90 ms 56.24 ms
3615e19 468.38 ms 504.71 ms 36.33 ms
0265ce5 406.39 ms 418.48 ms 12.09 ms
9b99523 456.91 ms 490.55 ms 33.64 ms
c97f488 502.43 ms 492.47 ms -9.97 ms
67de70c 375.88 ms 356.11 ms -19.77 ms

App size

Revision Plain With Sentry Diff
4298701 6.54 MiB 7.71 MiB 1.17 MiB
e200a70 13.93 MiB 15.18 MiB 1.25 MiB
ec78888 6.54 MiB 7.69 MiB 1.15 MiB
af96ef2 13.93 MiB 15.18 MiB 1.25 MiB
79f6b41 6.54 MiB 7.69 MiB 1.15 MiB
3615e19 6.54 MiB 7.70 MiB 1.16 MiB
0265ce5 14.09 MiB 15.28 MiB 1.19 MiB
9b99523 6.54 MiB 7.69 MiB 1.15 MiB
c97f488 14.31 MiB 15.49 MiB 1.19 MiB
67de70c 14.31 MiB 15.49 MiB 1.19 MiB

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

Startup times

Revision Plain With Sentry Diff
f96a725 411.33 ms 420.06 ms 8.73 ms
e3bfa44 390.52 ms 373.63 ms -16.89 ms
80a6525 386.66 ms 386.65 ms -0.01 ms
a48e7d7 371.18 ms 361.09 ms -10.09 ms
7c249a7 366.72 ms 369.06 ms 2.34 ms
e3d200a 421.91 ms 432.42 ms 10.51 ms

App size

Revision Plain With Sentry Diff
f96a725 14.31 MiB 15.49 MiB 1.19 MiB
e3bfa44 14.31 MiB 15.49 MiB 1.19 MiB
80a6525 14.31 MiB 15.49 MiB 1.19 MiB
a48e7d7 14.31 MiB 15.49 MiB 1.19 MiB
7c249a7 14.31 MiB 15.49 MiB 1.19 MiB
e3d200a 14.31 MiB 15.49 MiB 1.19 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
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.

Comment thread packages/dart/lib/src/protocol/dsn.dart
Comment thread packages/dart/lib/src/utils/tracing_utils.dart
@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

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
2700 1 2699 0
View the top 2 failed test(s) by shortest run time
test.frame_tracking.frames_tracking_integration_test.dart::succeeds to initialize frames tracking measures frames
Stack Traces | 3.75s run time
Error:

Test failed. See exception logs above.
The test description was: measures frames
test.sentry_supabase_error_client_test.dart::Error should capture error if send throws
Stack Traces | 7.04s run time
Failure:

Expected: <1>
  Actual: <4>

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

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

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