Skip to content

fix(replay): Move error sampling to before send - #8057

Merged
mydea merged 5 commits into
developfrom
fix-replay-sampling-happens-too-late-incorrect-tagging
May 8, 2023
Merged

fix(replay): Move error sampling to before send #8057
mydea merged 5 commits into
developfrom
fix-replay-sampling-happens-too-late-incorrect-tagging

Conversation

@billyvg

@billyvg billyvg commented May 5, 2023

Copy link
Copy Markdown
Member

In buffer mode, we were always tagging error events even if it was not sampled. This is because the sampling decision was moved from the initialization of the SDK to much further down the pipeline to right before flushing a replay. We now handle sampling of the error event before tagging event with replayId, and in the afterSend callback, we consider an error event as sampled if it has a replayId.

Closes #8055

@billyvg billyvg changed the title fix replay sampling happens too late incorrect tagging fix(replay): Move error sampling to before send May 5, 2023
@billyvg
billyvg requested a review from mydea May 5, 2023 21:34
@billyvg
billyvg marked this pull request as ready for review May 5, 2023 21:34
@github-actions

github-actions Bot commented May 5, 2023

Copy link
Copy Markdown
Contributor

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.02 KB (0%)
@sentry/browser - ES5 CDN Bundle (minified) 65.62 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 19.55 KB (0%)
@sentry/browser - ES6 CDN Bundle (minified) 58.08 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.16 KB (0%)
@sentry/browser - Webpack (minified) 69.03 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.18 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 49.09 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 28.64 KB (0%)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 26.86 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 47.16 KB (+0.55% 🔺)
@sentry/replay - Webpack (gzipped + minified) 40.94 KB (+0.56% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 66.1 KB (+0.47% 🔺)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 58.99 KB (+0.52% 🔺)

billyvg added 4 commits May 5, 2023 18:32
In buffer mode, we were always tagging error events even if it was not sampled. This is because the sampling decision was moved from the initialization of the SDK to much further down the pipeline to right before flushing a replay. We now handle sampling of the error event before tagging event with replayId, and in the afterSend callback, we consider an error event as sampled if it has a replayId.
@billyvg
billyvg force-pushed the fix-replay-sampling-happens-too-late-incorrect-tagging branch from 9d724a3 to 1319822 Compare May 5, 2023 22:38
return;
}

if (replay.recordingMode === 'buffer' && event.tags && event.tags.replayId) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I love this, much clearer than before! 🎉

@mydea

mydea commented May 8, 2023

Copy link
Copy Markdown
Member

I was so free to do a very minor refactor (I combined shouldTrySampleEvent() && isSampled() into shouldSampleForBufferEvent(), as I was initially a bit confused by this). Will merge this and include in the next release! 🚀

@mydea
mydea merged commit d8cf8d3 into develop May 8, 2023
@mydea
mydea deleted the fix-replay-sampling-happens-too-late-incorrect-tagging branch May 8, 2023 08:20
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.

Replay: Events tagged with replay_id before sampling decision

2 participants