feat(span-first): Add TTID/TTFD instrumentation#3532
feat(span-first): Add TTID/TTFD instrumentation#3532buenaflor merged 20 commits intofeat/span-firstfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace inline TTID/TTFD streaming code in SentryNavigatorObserver with TimeToDisplayTrackerV2.trackRoute(). Remove static ttfdSpan field and route SentryDisplay/SentryFlutter.currentDisplay() through the tracker on SentryFlutterOptions. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
…aming integration tests Make timeToDisplayTrackerV2 a non-nullable late field on SentryFlutterOptions instead of being created and set by SentryNavigatorObserver. Add didPop handling for streaming mode and integration tests covering the full span v2 TTID/TTFD lifecycle through the navigator observer. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
|
@sentry review |
|
@cursor review |
packages/flutter/lib/src/navigation/sentry_navigator_observer.dart
Outdated
Show resolved
Hide resolved
|
@cursor review |
|
@sentry review |
packages/flutter/lib/src/navigation/sentry_navigator_observer.dart
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Pull request overview
This PR adds streaming-mode TTID (Time To Initial Display) and TTFD (Time To Full Display) instrumentation for Flutter navigation. It introduces TimeToDisplayTrackerV2 which uses the new span-first architecture with idle spans to track route display timing, alongside conditional routing logic to support both legacy and streaming trace lifecycles.
Changes:
- Added
TimeToDisplayTrackerV2class for streaming-mode TTID/TTFD tracking using idle spans - Updated Flutter navigation observer and display APIs to conditionally use V2 tracker when in streaming mode
- Changed default idle span timeout from 5 seconds to 3 seconds across the SDK
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/flutter/lib/src/navigation/time_to_display_tracker_v2.dart | New tracker implementation using idle spans for route-level TTID/TTFD tracking |
| packages/flutter/lib/src/sentry_flutter_options.dart | Added timeToDisplayTrackerV2 field initialization |
| packages/flutter/lib/src/sentry_flutter.dart | Updated currentDisplay() to conditionally return V2 span IDs in streaming mode |
| packages/flutter/lib/src/navigation/sentry_navigator_observer.dart | Added V2 tracker initialization and conditional routing in didPush/didPop |
| packages/flutter/lib/src/navigation/sentry_display.dart | Updated reportFullyDisplayed() to conditionally call V2 tracker and improved error logging |
| packages/dart/lib/src/noop_hub.dart | Changed startIdleSpan default idleTimeout from 5s to 3s |
| packages/dart/lib/src/hub_adapter.dart | Changed startIdleSpan default idleTimeout from 5s to 3s |
| packages/flutter/example/lib/auto_close_screen.dart | Moved Dio instance to class field (lifecycle change) |
| packages/flutter/test/navigation/time_to_display_tracker_v2_test.dart | Comprehensive unit tests for TimeToDisplayTrackerV2 |
| packages/flutter/test/navigation/sentry_navigator_observer_test.dart | Added streaming mode integration tests |
| packages/flutter/test/navigation/sentry_display_test.dart | Added tests for both streaming and non-streaming modes |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@cursor review |
| SentrySpanV2 startIdleSpan( | ||
| String name, { | ||
| Duration idleTimeout = const Duration(seconds: 5), | ||
| Duration idleTimeout = const Duration(seconds: 3), |
There was a problem hiding this comment.
default should be 3 seconds
packages/flutter/lib/src/navigation/sentry_navigator_observer.dart
Outdated
Show resolved
Hide resolved
packages/flutter/test/navigation/sentry_navigator_observer_test.dart
Outdated
Show resolved
Hide resolved
packages/flutter/lib/src/navigation/time_to_display_tracker_v2.dart
Outdated
Show resolved
Hide resolved
…ming tests Guard TTFD span creation behind enableTimeToFullDisplayTracing option. Refactor observer streaming tests to use a fake tracker, verifying method calls instead of re-testing tracker internals. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with Cloud Agents, enable Autofix in the Cursor dashboard.
Implement a debug log to indicate when Time To Full Display (TTFD) tracing is disabled, returning null for currentDisplay accordingly. This enhances traceability and debugging for TTFD-related functionality.
…et test currentDisplay() now guards on this option, so the test fixture needs it set to true for reportFullyDisplayed to be called. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📜 Description
Adds streaming route TTID/TTFD span tracking (
TimeToDisplayTrackerV2) and wires it through Flutter navigation/display APIs.💡 Motivation and Context
Part of Span First of porting TTID/TTFD
💚 How did you test it?
fvm flutter test test/navigation/time_to_display_tracker_v2_test.dart test/navigation/sentry_navigator_observer_test.dart📝 Checklist
sendDefaultPiiis enabled🔮 Next steps
#skip-changelog