Problem
syncPropagationContextToNative (added in #6686) fires on every root span via the spanStart hook. Background/inactive roots created with startInactiveSpan({ forceTransaction: true }) — app-start in integrations/appStart.ts — also trigger a sync, overwriting the native scope with their traceId/spanId while a navigation root may already be active. When these background roots end, there is no restore, so in-flight native HTTP requests (OkHttp / URLSession) get attributed to the wrong trace.
A secondary issue: sampleRand is read from getCurrentScope().getPropagationContext() at sync time, which can be stale for these background roots since they don't update the propagation context before starting (unlike idle navigation spans).
Steps to reproduce
- App-start span fires mid-navigation
- Native HTTP request starts during the navigation transaction
- The request is linked to the app-start trace instead of the navigation trace
Expected
Background/inactive root spans should not overwrite the native propagation context when an active navigation trace is already set.
Possible fix
Move the sync out of the generic spanStart hook and into startIdleNavigationSpan directly, after the span is made active. This naturally excludes background roots without needing to filter by op or attributes.
Problem
syncPropagationContextToNative(added in #6686) fires on every root span via thespanStarthook. Background/inactive roots created withstartInactiveSpan({ forceTransaction: true })— app-start inintegrations/appStart.ts— also trigger a sync, overwriting the native scope with theirtraceId/spanIdwhile a navigation root may already be active. When these background roots end, there is no restore, so in-flight native HTTP requests (OkHttp / URLSession) get attributed to the wrong trace.A secondary issue:
sampleRandis read fromgetCurrentScope().getPropagationContext()at sync time, which can be stale for these background roots since they don't update the propagation context before starting (unlike idle navigation spans).Steps to reproduce
Expected
Background/inactive root spans should not overwrite the native propagation context when an active navigation trace is already set.
Possible fix
Move the sync out of the generic
spanStarthook and intostartIdleNavigationSpandirectly, after the span is made active. This naturally excludes background roots without needing to filter by op or attributes.