-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
docs(session-replay): Add comprehensive explanation of sampling mechanism #15941
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
base: master
Are you sure you want to change the base?
docs(session-replay): Add comprehensive explanation of sampling mechanism #15941
Conversation
…nism - Explain memory buffer system - Document sampling decision flow - Add user scenario examples - Include technical implementation details
|
@cjy3458 is attempting to deploy a commit to the Sentry Team on Vercel. A member of the Team first needs to authorize it. |
| - Old events are automatically overwritten | ||
| - No memory leak concerns | ||
| - Stops recording after 60 minutes (hard limit) | ||
| - Pauses when internet connection is lost |
This comment was marked as outdated.
This comment was marked as outdated.
Sorry, something went wrong.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pause-on-connection-loss feature is specific to mobile SDKs, not web SDKs. Removed to avoid confusion.
|
Hi team! 👋 Friendly ping - all CI checks passed and this is ready for review whenever the team has time! Let me know if you need any clarifications. Thanks! 🙏 |
philprime
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for opening up this PR. We appreciate everyone contributing to Sentry. I left a couple of high-priority comments we need to address. Overall I currently do not see the clear benefit of this page, as it mentions a lot of information we already have on our platform-specific session-replay related documentation for Web, Android and iOS (I am one of the iOS maintainers).
I'll leave it to the @getsentry/product-owners-docs to decide on how to proceed with this contribution, but I do not believe we can merge it as it is right now.
|
|
||
| ### What Gets Stored | ||
|
|
||
| Contrary to what you might expect, Session Replay doesn't store actual video files in memory. Instead, it stores **event logs** in a structured format: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: This applies to web, not to mobile. As this is a product page for a feature spanning all platforms we must either not mention this or make it clear that it's different and explain both applications.
|
|
||
| ### Buffer Duration and Size | ||
|
|
||
| - **Duration**: 60 seconds of the most recent activity |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: This can easily be outdated and can be different per platform (it's 30 seconds for iOS apps)
| ### Configuration Example | ||
| ```javascript | ||
| Sentry.init({ | ||
| dsn: 'YOUR_DSN', | ||
| replaysSessionSampleRate: 0.1, // 10% of users | ||
| replaysOnErrorSampleRate: 1.0, // 100% of error-encountering users | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: This can become outdated, let's reference the actual product page per platform instead using PlatformLink
| - If selected (10% chance): Full session recording starts immediately → sent to Sentry in real-time | ||
| - If not selected (90% chance): Recording starts but stays in memory buffer only |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: Let's not add percentages here, as they are configurable:
| - If selected (10% chance): Full session recording starts immediately → sent to Sentry in real-time | |
| - If not selected (90% chance): Recording starts but stays in memory buffer only | |
| - If selected: Full session recording starts immediately → sent to Sentry in real-time | |
| - If not selected: Recording starts but stays in memory buffer only |
|
|
||
| 2. **Error Trigger** | ||
| - If an error occurs and `replaysOnErrorSampleRate` condition is met: | ||
| - The buffered 60 seconds *before* the error is captured |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| - The buffered 60 seconds *before* the error is captured | |
| - The buffered 60 seconds (or as configured) *before* the error is captured |
|
|
||
| ### Memory Management | ||
|
|
||
| The 60-second buffer is managed as a **ring buffer**: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
h: This is also different per platform. On mobile we take screenshots, mask them, then combine them into videos on-device after X seconds
| ### Recommended Configuration | ||
| ```javascript | ||
| Sentry.init({ | ||
| dsn: 'YOUR_DSN', | ||
|
|
||
| // Capture 10% of sessions for general monitoring | ||
| replaysSessionSampleRate: 0.1, | ||
|
|
||
| // Capture 100% of sessions where errors occur | ||
| replaysOnErrorSampleRate: 1.0, | ||
| }); | ||
| ``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
m: This does not match the recommendation we already have in place: https://docs.sentry.io/platforms/javascript/session-replay/#recommended-production-sample-rates
…dress review feedback - Relocate from product-level to Web-specific location (docs/product/explore/session-replay/ → docs/platforms/javascript/common/session-replay/) - Address all 7 review comments from @philiprime Changes: - Add Web-specific disclaimer and platform callouts (getsentry#1, getsentry#6) - Change buffer duration to configurable with platform notes (getsentry#2) - Replace config examples with PlatformLink references (getsentry#3) - Remove hardcoded percentages from decision flow (getsentry#4) - Add '(or as configured)' qualifiers (getsentry#5) - Remove duplicate 'Recommended Configuration' section (getsentry#7) The document now focuses on Web's internal mechanism (rrweb, DOM events, ring buffer) while deferring configuration to official setup docs."
|
All 7 review comments addressed! 🙏 Main changes: ✅ Structural:
✅ Content:
Result: Document now focuses on Web's internal mechanism while linking to official docs for configuration. Ready for re-review! 🚀 |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
1 Skipped Deployment
|
DESCRIBE YOUR PR
This PR adds comprehensive documentation explaining how Sentry's Session Replay sampling mechanism works internally.
Problem: Many developers find it confusing how
replaysSessionSampleRateandreplaysOnErrorSampleRatework together, especially regarding the memory buffer system and when data is actually sent to Sentry.Solution: Added detailed technical documentation that explains:
This documentation will help developers better understand the internal mechanisms and optimize their Session Replay configuration.
IS YOUR CHANGE URGENT?
SLA
PRE-MERGE CHECKLIST
(External contributor - waiting for team authorization)
NOTE FOR REVIEWERS
As an external contributor, I'm unable to access the Vercel preview until authorized. I've tested the markdown formatting and links locally using
yarn dev. Please let me know if you spot any issues in the preview!LEGAL BOILERPLATE
I retain all rights, title and interest in and to my contributions, and by keeping this boilerplate intact I confirm that Sentry can use, modify, copy, and redistribute my contributions, under Sentry's choice of terms.