feat: Add basic lifecycle instrumentation. #245
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Adds basic support for lifecycle instrumentation.
The code inside the
instrumentation/lifecycle/platformfolder is a port of the code in the LD flutter SDK. Potentially we could move that to a shared library. We split the LD SDK into layers, but there wasn't any need for a flutter specific platform layer sans SDK. (It is dart only, then client-side dart, and then flutter. But no flutter platform library.)How did you test this change?
Manual testing.
Note
Introduce lifecycle instrumentation that emits spans on Flutter app state changes across IO and Web platforms, and wire it into the observability plugin.
Instrumentationinterface andLifecycleInstrumentationthat listens toAppLifecycleStateand emits spans viaObservewith attributes fromLifecycleConventions.LifecycleConventionswith span namedevice.app.lifecycleand attributeflutter.app.statemapped fromAppLifecycleState.platform/io_lifecycle_listener.dart(usesAppLifecycleListener) andplatform/js_lifecycle_listener.dart(uses document visibility); include a stub fallback.ObservabilityPluginto instantiate and holdLifecycleInstrumentationon construction.Written by Cursor Bugbot for commit d150c19. This will update automatically on new commits. Configure here.