-
-
Notifications
You must be signed in to change notification settings - Fork 359
Description
Environment
@sentry/react-native(all versions withappStartIntegration)- Any
tracesSampleRateless than1.0
Steps to Reproduce
- Configure Sentry with
tracesSampleRateless than1.0(e.g.,0.5) - Launch the app so that a Cold/Warm Start is measured by the native layer
- The first root span (navigation transaction) happens to be unsampled
Expected Result
App start data (Cold/Warm Start spans and measurements) is attached to the next sampled transaction.
Actual Result
App start data is permanently lost for that session. No sampled transaction ever receives it.
Root Cause
In appStartIntegration, recordFirstStartedActiveRootSpanId locks firstStartedActiveRootSpanId to the first root span that starts, regardless of whether it is sampled. Since processEvent only runs for sampled events, the span ID match check at:
if (firstStartedActiveRootSpanId !== event.contexts.trace.span_id) {
return;
}will always fail for every subsequent sampled transaction, because the stored ID belongs to the unsampled span that was never sent.
At lower sample rates this is statistically very likely. For example at tracesSampleRate: 0.1, there's a 90% chance the first transaction is unsampled, meaning 90% of sessions lose app start data entirely.