feat(span): Add public startInactiveSpan API#3568
Merged
buenaflor merged 4 commits intofeat/span-firstfrom Mar 18, 2026
Merged
Conversation
Expose startInactiveSpan on the Sentry class as a public static method, mirroring the existing startSpan API. Unlike startSpan, this creates a span that is not set as the active span and must be ended manually, useful for spans that survive across execution boundaries like widget lifecycles or stream subscriptions. Remove @internal annotation from Hub.startInactiveSpan. Co-Authored-By: Claude <noreply@anthropic.com>
Contributor
|
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces a new public API for creating “inactive” (non-zone-propagated) span v2 instances via Sentry.startInactiveSpan(), and makes the underlying Hub.startInactiveSpan() method publicly accessible by removing its @internal annotation.
Changes:
- Add
Sentry.startInactiveSpan()as a public static API (with dartdoc) to create spans whose lifetime is managed manually. - Remove
@internalfromHub.startInactiveSpan()so the hub-level API is no longer marked internal.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| packages/dart/lib/src/sentry.dart | Adds the new public Sentry.startInactiveSpan() wrapper and documentation. |
| packages/dart/lib/src/hub.dart | Exposes Hub.startInactiveSpan() by removing the @internal annotation. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
denrase
approved these changes
Mar 17, 2026
Collaborator
denrase
left a comment
There was a problem hiding this comment.
LGTM, worth checking if Copilot review has valid points.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
…activeSpan methods Updated the startInactiveSpan method across Hub, NoOpHub, and Sentry classes to ensure the parentSpan parameter is consistently placed at the end of the parameter list. This change improves code readability and maintains uniformity in method signatures.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Add
Sentry.startInactiveSpan()as a public static method, complementing the existingSentry.startSpan()callback-based API.Unlike
startSpan, inactive spans are not set as the active span and are not propagated through zones. They must be ended manually viaSentrySpanV2.end(). This is useful for spans that survive across execution boundaries that a callback cannot wrap — widget lifecycles, stream subscriptions, or platform channel round-trips.Changes:
Sentry.startInactiveSpan()static method insentry.dart@internalannotation fromHub.startInactiveSpan()#skip-changelog