feat(tracing): Simplify span v2 status to ok/error#3840
Conversation
Reduce SentrySpanStatusV2 to `ok` and `error`, removing `cancelled` and `deadlineExceeded`, and define how v2 idle spans finish: - finalTimeout: error + `sentry.status.message` = `deadline_exceeded` - idleTimeout: ok - still-active children force-finished on timeout: ok - external cancel (route change, different-widget tap): ok + `sentry.idle_span_finish_reason` = `cancelled` Co-Authored-By: Claude <noreply@anthropic.com>
Semver Impact of This PR🟡 Minor (new features) 📋 Changelog PreviewThis is how your changes will appear in the changelog. FeaturesDart
Other
Fixes
Enhancements
DependenciesDeps
Internal Changes
🤖 This preview updates automatically when you update the PR. |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #3840 +/- ##
==========================================
+ Coverage 87.34% 87.39% +0.04%
==========================================
Files 337 337
Lines 12205 12205
==========================================
+ Hits 10660 10666 +6
+ Misses 1545 1539 -6
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
iOS Performance metrics 🚀
|
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 192b44c | 1269.08 ms | 1275.52 ms | 6.44 ms |
| eca355d | 1238.39 ms | 1266.98 ms | 28.59 ms |
| 79f6b41 | 1269.33 ms | 1279.71 ms | 10.38 ms |
| c26ed0a | 1244.11 ms | 1263.85 ms | 19.75 ms |
| ea06d23 | 1254.02 ms | 1252.60 ms | -1.42 ms |
| a2c8611 | 1253.83 ms | 1246.92 ms | -6.91 ms |
| f42e9fb | 1247.60 ms | 1255.89 ms | 8.29 ms |
| d052aef | 1246.33 ms | 1253.04 ms | 6.71 ms |
| de377fd | 1252.28 ms | 1254.76 ms | 2.48 ms |
| dc53d48 | 1252.06 ms | 1255.61 ms | 3.55 ms |
App size
| Revision | Plain | With Sentry | Diff |
|---|---|---|---|
| 192b44c | 5.53 MiB | 5.96 MiB | 444.33 KiB |
| eca355d | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| 79f6b41 | 7.86 MiB | 9.44 MiB | 1.58 MiB |
| c26ed0a | 5.53 MiB | 5.97 MiB | 453.76 KiB |
| ea06d23 | 5.53 MiB | 5.96 MiB | 443.26 KiB |
| a2c8611 | 5.66 MiB | 6.10 MiB | 452.11 KiB |
| f42e9fb | 5.83 MiB | 6.28 MiB | 462.32 KiB |
| d052aef | 5.73 MiB | 6.17 MiB | 453.76 KiB |
| de377fd | 20.71 MiB | 22.43 MiB | 1.73 MiB |
| dc53d48 | 5.65 MiB | 6.09 MiB | 446.96 KiB |
There was a problem hiding this comment.
Pull request overview
This PR simplifies the v2 span status model in the streaming telemetry pipeline by reducing SentrySpanStatusV2 to just ok/error, and moves idle-span “why it ended” semantics onto semantic attributes set at finish time (e.g. sentry.status.message=deadline_exceeded and sentry.idle_span_finish_reason=cancelled).
Changes:
- Remove
cancelledanddeadlineExceededfromSentrySpanStatusV2and update status conversions accordingly. - Set semantic attributes on idle span final-timeout (
sentry.status.message) and external-cancel flows (sentry.idle_span_finish_reason) while keeping status asok/error. - Update Dart + Flutter tests to validate the new status/attribute behavior.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/flutter/test/user_interaction/sentry_user_interaction_widget_test.dart | Updates expectations to ok + sentry.idle_span_finish_reason=cancelled. |
| packages/flutter/test/navigation/time_to_display_tracker_v2_test.dart | Updates route-cancel test expectations to ok + cancelled finish reason; renames a test accordingly. |
| packages/flutter/lib/src/user_interaction/sentry_user_interaction_widget.dart | On superseding interaction, ends prior idle span with ok and sets cancelled finish-reason attribute. |
| packages/flutter/lib/src/navigation/time_to_display_tracker_v2.dart | On route cancel, ends active idle span with ok and sets cancelled finish-reason attribute. |
| packages/dart/test/hub_span_test.dart | Updates idle-span timeout semantics tests and adds coverage for idle-timeout resulting in ok and no status-message attribute. |
| packages/dart/lib/src/tracing/instrumentation/instrumentation_span.dart | Simplifies v2↔v1 status mapping now that v2 only has ok/error. |
| packages/dart/lib/src/telemetry/span/sentry_span_status_v2.dart | Removes cancelled/deadlineExceeded enum values, leaving only ok/error. |
| packages/dart/lib/src/telemetry/span/idle_recording_sentry_span_v2.dart | Sets error + sentry.status.message=deadline_exceeded on final timeout; force-finished children now end with ok. |
| packages/dart/lib/src/constants.dart | Adds internal semantic attribute keys for status message and idle-span finish reason. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace the inline 'deadline_exceeded' and 'cancelled' attribute-value literals with named constants in constants.dart. 'cancelled' was duplicated across two production call sites; centralizing avoids drift. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
| @@ -1,7 +1,5 @@ | |||
| enum SentrySpanStatusV2 { | |||
There was a problem hiding this comment.
If what warden says is correct, we should at least mark it now as internal, no?
There was a problem hiding this comment.
imo it's okay, span-streaming is not yet GA (no docs, etc...)
| } | ||
|
|
||
| SentrySpanStatusV2 _convertToV2Status(SpanStatus status) { | ||
| if (status == SpanStatus.ok()) { |
There was a problem hiding this comment.
Are there now cases in SpanStatus that would also match to error, like deadlineExceeded?
There was a problem hiding this comment.
yeah, which is fine imo. I dont expect this to be perfect now
Closes #3839
SentrySpanStatusV2now only distinguishesokfromerror. ThecancelledanddeadlineExceededvalues are removed, and the finer-grained outcome of a v2 idle span moves onto semantic attributes set when the span finishes:errorsentry.status.message=deadline_exceededokokoksentry.idle_span_finish_reason=cancelledsentry.idle_span_finish_reasonmirrors the JS SDK'sbrowserTracingIntegration. Two new@internalSemanticAttributesConstantsback these attributes:sentryStatusMessageandsentryIdleSpanFinishReason.SentrySpanStatusV2is@internaland not exported from any public barrel, so SDK users are unaffected. The v1SpanStatus(cancelled()/deadlineExceeded()) is a separate protocol type and is left untouched — its use in gRPC and the v1 navigation trackers is unchanged.