Skip to content

feat(span): Add public startInactiveSpan API#3568

Merged
buenaflor merged 4 commits intofeat/span-firstfrom
feat/span/inactive-span
Mar 18, 2026
Merged

feat(span): Add public startInactiveSpan API#3568
buenaflor merged 4 commits intofeat/span-firstfrom
feat/span/inactive-span

Conversation

@buenaflor
Copy link
Copy Markdown
Contributor

@buenaflor buenaflor commented Mar 17, 2026

Add Sentry.startInactiveSpan() as a public static method, complementing the existing Sentry.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 via SentrySpanV2.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:

  • Add Sentry.startInactiveSpan() static method in sentry.dart
  • Remove @internal annotation from Hub.startInactiveSpan()

#skip-changelog

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>
@buenaflor buenaflor changed the base branch from main to feat/span-first March 17, 2026 15:12
@buenaflor buenaflor marked this pull request as ready for review March 17, 2026 15:12
@buenaflor buenaflor requested a review from denrase as a code owner March 17, 2026 15:12
Copilot AI review requested due to automatic review settings March 17, 2026 15:12
@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 64f5bff

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 @internal from Hub.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.

Copy link
Copy Markdown
Collaborator

@denrase denrase left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, worth checking if Copilot review has valid points.

buenaflor and others added 3 commits March 18, 2026 11:37
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.
@buenaflor buenaflor merged commit ca53a7d into feat/span-first Mar 18, 2026
138 of 140 checks passed
@buenaflor buenaflor deleted the feat/span/inactive-span branch March 18, 2026 10:53
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.

3 participants