Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(replay): Ignore older performance entries when starting manually #13969

Merged
merged 2 commits into from
Oct 17, 2024

Conversation

mydea
Copy link
Member

@mydea mydea commented Oct 14, 2024

For replay, performance entries are captured separately, and added to the replay before we send it.
Generally, this works just fine, because when we buffer, we clear the captured performance events whenever the buffer is cleared.

However, when we manually start the replay, it can happen that we capture performane entries from way before we started the replay manually, which will in turn extend the timeline of the replay potentially drastically.

To fix this, we now drop any performance events, when starting manually, that happened more than a second before we manually started the replay.

The 1s is an arbitrary number to accomodate the fact that some entries can be emitted slightly before - when we immediately run replay.start() we generally want to try to keep those too.

@mydea mydea requested review from billyvg and chargome October 14, 2024 08:03
@mydea mydea self-assigned this Oct 14, 2024
@mydea mydea requested a review from a team as a code owner October 14, 2024 08:03
@mydea mydea added the Package: replay Issues related to the Sentry Replay SDK label Oct 14, 2024
Copy link
Contributor

github-actions bot commented Oct 14, 2024

size-limit report 📦

Path Size % Change Change
@sentry/browser 22.73 KB - -
@sentry/browser - with treeshaking flags 21.53 KB - -
@sentry/browser (incl. Tracing) 35.12 KB - -
@sentry/browser (incl. Tracing, Replay) 71.86 KB +0.04% +26 B 🔺
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 62.26 KB +0.04% +25 B 🔺
@sentry/browser (incl. Tracing, Replay with Canvas) 76.21 KB +0.03% +20 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback) 89 KB +0.03% +26 B 🔺
@sentry/browser (incl. Tracing, Replay, Feedback, metrics) 90.82 KB +0.03% +26 B 🔺
@sentry/browser (incl. metrics) 27 KB - -
@sentry/browser (incl. Feedback) 39.87 KB - -
@sentry/browser (incl. sendFeedback) 27.38 KB - -
@sentry/browser (incl. FeedbackAsync) 32.17 KB - -
@sentry/react 25.49 KB - -
@sentry/react (incl. Tracing) 38.09 KB - -
@sentry/vue 26.91 KB - -
@sentry/vue (incl. Tracing) 37.02 KB - -
@sentry/svelte 22.87 KB - -
CDN Bundle 24.11 KB - -
CDN Bundle (incl. Tracing) 36.96 KB - -
CDN Bundle (incl. Tracing, Replay) 71.65 KB +0.04% +25 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) 76.99 KB +0.04% +28 B 🔺
CDN Bundle - uncompressed 70.7 KB - -
CDN Bundle (incl. Tracing) - uncompressed 109.73 KB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 222.24 KB +0.04% +75 B 🔺
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 235.46 KB +0.04% +75 B 🔺
@sentry/nextjs (client) 38.06 KB - -
@sentry/sveltekit (client) 35.74 KB - -
@sentry/node 125.15 KB - -
@sentry/node - without tracing 94.25 KB - -
@sentry/aws-serverless 103.81 KB - -

View base workflow run

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Thanks for adding this!

Comment on lines 1061 to 1062
// We leave 1s wiggle room to accomodate timing differences for "immedidate" manual starts
const initialTimestampInSeconds = this._context.initialTimestamp / 1000 - 1;
Copy link
Member

Choose a reason for hiding this comment

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

Do we want the wiggle room? Since it's manual start, I think it's ok to only capture events after start. It's easier to explain to users as well.

Copy link
Member Author

Choose a reason for hiding this comment

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

the problem is that if you have code like this, I guess:

Sentry.init({
  replaysErrorSampleRate: 0,
  replaysSessionSampleRate: 0, 
  integrations: [replay]
});

if (isImportantUser) {
  replay.start();
}

Like this kind of pattern, where users start manually but "immediately", we would otherwise probably miss many of the page load performance entries, as they are often correctly pre-dated to Date.now() 🤔 but no strong feelings, it is a bit "random". happy to generally remove the wiggle room!

Copy link
Member

Choose a reason for hiding this comment

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

Ah didn't consider that... I think we keep it simple and remove the wiggle room, but don't feel strongly about this.

@mydea mydea force-pushed the fn/replay-performance-buffer branch from 5ee3f10 to e861f46 Compare October 17, 2024 18:32
@mydea
Copy link
Member Author

mydea commented Oct 17, 2024

I removed the wiggle room, I left in the test that shows the current behavior for immediate start as well :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Package: replay Issues related to the Sentry Replay SDK
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants