Problem Statement
There's no supported way for app code to say "start a new trace here." Trace boundaries are currently only ever created by:
SentryNavigatorObserver on navigation events
- App foreground/background transitions (mobile, 30s threshold)
Everything that manages this — Hub.generateNewTrace(), Scope.propagationContext, and the PropagationContext class itself — is marked @internal.
This is a real gap for apps with background work that isn't tied to navigation: polling loops, timers, retries, or any repeated operation that runs for as long as a screen stays open. Any such call falls back to Sentry.startTransaction() when it has no active parent span — but that transaction still inherits whatever trace_id is sitting in the scope from the last navigation event, even if that navigation's transaction finished seconds or minutes ago. The result: unrelated background operations all get glued into one trace that spans the entire screen session, rather than each getting its own trace.
Solution Brainstorm
Comparison to @sentry/core (JS)
The JavaScript SDK exposes exactly this as a stable, documented, public function:
export function startNewTrace(): void
used precisely for this scenario (SPA route changes without a router integration). The Dart/Flutter SDK has the equivalent capability (Hub.generateNewTrace()), it's just never been promoted out of @internal.
Workaround today
// ignore: invalid_use_of_internal_member
Sentry.currentHub.generateNewTrace();
This works (it's literally what SentryNavigatorObserver calls internally), but it's not covered by semver guarantees, so a minor/patch bump could rename or remove it without a deprecation cycle.
Ask
Expose a public, stable API — e.g. Sentry.startNewTrace() — mirroring the JS SDK, so apps with non-navigation-driven background work can manage trace boundaries without reaching into @internal SDK guts.
Are you willing to submit a PR?
None
Problem Statement
There's no supported way for app code to say "start a new trace here." Trace boundaries are currently only ever created by:
SentryNavigatorObserveron navigation eventsEverything that manages this —
Hub.generateNewTrace(),Scope.propagationContext, and thePropagationContextclass itself — is marked@internal.This is a real gap for apps with background work that isn't tied to navigation: polling loops, timers, retries, or any repeated operation that runs for as long as a screen stays open. Any such call falls back to
Sentry.startTransaction()when it has no active parent span — but that transaction still inherits whatevertrace_idis sitting in the scope from the last navigation event, even if that navigation's transaction finished seconds or minutes ago. The result: unrelated background operations all get glued into one trace that spans the entire screen session, rather than each getting its own trace.Solution Brainstorm
Comparison to
@sentry/core(JS)The JavaScript SDK exposes exactly this as a stable, documented, public function:
used precisely for this scenario (SPA route changes without a router integration). The Dart/Flutter SDK has the equivalent capability (
Hub.generateNewTrace()), it's just never been promoted out of@internal.Workaround today
This works (it's literally what
SentryNavigatorObservercalls internally), but it's not covered by semver guarantees, so a minor/patch bump could rename or remove it without a deprecation cycle.Ask
Expose a public, stable API — e.g.
Sentry.startNewTrace()— mirroring the JS SDK, so apps with non-navigation-driven background work can manage trace boundaries without reaching into@internalSDK guts.Are you willing to submit a PR?
None