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

feat(replay): Re-sample sessions after they expire #8407

Closed
wants to merge 2 commits into from

Conversation

mydea
Copy link
Member

@mydea mydea commented Jun 27, 2023

This PR changes the replay session expiry behavior fundamentally.

Old behavior

  • When any session becomes too long (>60min), or the last user activity was >15min ago, we either
    • stop replay when it is an error session
    • or refresh the session if it is a "session" session
  • For non-buffering sessions, after 5 min we pause recording events until a user action happens

New behavior

  • Buffering session never expire and are never paused.
  • When any session (buffer or session) becomes too long, we stop the session and start new sampling
    • Based on sample rates, we call either .start() or .startBufffering() (or nothing if both sample rates are 0).
  • After 5min of inactivity, when not in buffer mode, we pause recording
  • We do not check 15min inactivity anymore, instead sessions continue to max. age and are restarted. The reason is that with the new logic you'd never get into this branch, because you'd always end up in paused state first anyhow.

This is quite a change and touches a bunch of places, and required changes to a bunch of tests. So although it's a bit hard to review, we should be very careful with this. But overall, it appears to be clearer to me anyhow what is happening.

Closes #8257
Closes #8400

@mydea mydea added the Package: replay Issues related to the Sentry Replay SDK label Jun 27, 2023
@mydea mydea requested a review from billyvg June 27, 2023 11:38
@mydea mydea self-assigned this Jun 27, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jun 27, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 21.95 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 69.13 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 20.28 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 60.38 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 21.9 KB (0%)
@sentry/browser - Webpack (minified) 71.51 KB (0%)
@sentry/react - Webpack (gzipped + minified) 21.92 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 50.76 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 30.33 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 28.2 KB (0%)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 49.42 KB (-0.05% 🔽)
@sentry/replay - Webpack (gzipped + minified) 43.03 KB (-0.3% 🔽)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 69.55 KB (-0.03% 🔽)
@sentry/browser + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.82 KB (-0.04% 🔽)

Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

I've only taken a quick glance at this, but the approach seems sound to me. Will have to give it a thorough read in the next day or two.

Copy link
Member

@billyvg billyvg left a comment

Choose a reason for hiding this comment

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

How can we test this on sentry.io before merging to master?

@mydea
Copy link
Member Author

mydea commented Jul 4, 2023

We could release an alpha if we're not 100% certain about it!

This is a PR to this feature branch:
#8407

* Handle edge case where we stop multiple times (honestly no idea how
this should happen, but apparently it can 😬 )
* Add some more logging for state changes

We can hopefully eventually remove the `traceInternals` checks, but for
now this is an easy solution for debugging in the beta....
@mydea
Copy link
Member Author

mydea commented Aug 17, 2023

Close in favor of #8834

@mydea mydea closed this Aug 17, 2023
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
2 participants