Skip to content

feat: Implement strict trace continuation#3567

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

feat: Implement strict trace continuation#3567
antonis wants to merge 8 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 1251.73 ms 1257.06 ms 5.33 ms
Size 5.73 MiB 6.17 MiB 456.50 KiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
5a95d04 1263.17 ms 1265.37 ms 2.20 ms
73a3c38 1263.37 ms 1277.90 ms 14.53 ms
4298701 1243.56 ms 1262.29 ms 18.72 ms
f872f8e 1253.29 ms 1250.49 ms -2.80 ms
3135a81 1258.11 ms 1247.48 ms -10.63 ms
cdf371b 1246.24 ms 1251.10 ms 4.86 ms
a909995 1259.83 ms 1258.66 ms -1.17 ms
765aa8b 1259.09 ms 1269.90 ms 10.82 ms
53356d8 1235.14 ms 1254.39 ms 19.24 ms
0fb3800 1256.60 ms 1266.28 ms 9.68 ms

App size

Revision Plain With Sentry Diff
5a95d04 5.53 MiB 6.01 MiB 487.81 KiB
73a3c38 7.86 MiB 9.44 MiB 1.58 MiB
4298701 20.70 MiB 22.46 MiB 1.76 MiB
f872f8e 5.53 MiB 5.96 MiB 444.81 KiB
3135a81 5.73 MiB 6.17 MiB 453.76 KiB
cdf371b 5.53 MiB 6.02 MiB 501.23 KiB
a909995 5.66 MiB 6.10 MiB 451.85 KiB
765aa8b 7.86 MiB 9.44 MiB 1.58 MiB
53356d8 5.66 MiB 6.10 MiB 451.56 KiB
0fb3800 7.86 MiB 9.44 MiB 1.58 MiB

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

Startup times

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

App size

Revision Plain With Sentry Diff
f96a725 5.73 MiB 6.17 MiB 456.50 KiB
7c249a7 5.73 MiB 6.17 MiB 456.52 KiB
80a6525 5.73 MiB 6.17 MiB 456.50 KiB
e3bfa44 5.73 MiB 6.17 MiB 456.50 KiB
a48e7d7 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 421.91 ms 432.42 ms 10.51 ms
Size 14.31 MiB 15.49 MiB 1.19 MiB

Baseline results on branch: main

Startup times

Revision Plain With Sentry Diff
ebccb5b 363.79 ms 371.10 ms 7.31 ms
cdf371b 367.64 ms 377.02 ms 9.38 ms
51520fc 351.89 ms 349.79 ms -2.10 ms
a34fde0 393.60 ms 389.96 ms -3.65 ms
aeb02f2 373.84 ms 437.00 ms 63.16 ms
c26ed0a 465.52 ms 476.38 ms 10.86 ms
1f639ee 429.98 ms 476.60 ms 46.62 ms
640ad0c 466.00 ms 552.67 ms 86.67 ms
4e14113 361.52 ms 353.19 ms -8.33 ms
8775665 415.88 ms 439.26 ms 23.38 ms

App size

Revision Plain With Sentry Diff
ebccb5b 13.93 MiB 15.18 MiB 1.25 MiB
cdf371b 13.93 MiB 15.18 MiB 1.25 MiB
51520fc 13.93 MiB 15.18 MiB 1.25 MiB
a34fde0 14.09 MiB 15.28 MiB 1.19 MiB
aeb02f2 6.54 MiB 7.69 MiB 1.15 MiB
c26ed0a 13.93 MiB 14.93 MiB 1.00 MiB
1f639ee 13.93 MiB 15.00 MiB 1.06 MiB
640ad0c 6.54 MiB 7.69 MiB 1.15 MiB
4e14113 14.09 MiB 15.28 MiB 1.19 MiB
8775665 13.93 MiB 15.18 MiB 1.25 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
7c249a7 366.72 ms 369.06 ms 2.34 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

App size

Revision Plain With Sentry Diff
f96a725 14.31 MiB 15.49 MiB 1.19 MiB
7c249a7 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

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.

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

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.

1 participant