Structured logs include replay_id when replay is not sampled
Closed this issue · 6 comments
Is there an existing issue for this?
- I have checked for existing issues https://github.com/getsentry/sentry-javascript/issues
- I have reviewed the documentation https://docs.sentry.io/
- I am using the latest SDK release https://github.com/getsentry/sentry-javascript/releases
How do you use Sentry?
Sentry Saas (sentry.io)
Which SDK are you using?
@sentry/react
SDK Version
10.12.0
Framework Version
No response
Link to Sentry event
No response
Reproduction Example/SDK Setup
No response
Steps to Reproduce
Structured logs are showing a replay_id even when the replay was not sampled due to replaysOnErrorSampleRate. This causes confusion since the replay can’t be found in Sentry.
- Configure SDK with replaysOnErrorSampleRate: 0.2 (or any low sample rate).
- Trigger an error in the app that incudes logs
- Notice that a replay_id tag is in the logs even when the replay was not actually captured / attatched to the error due to replaysOnErrorSampleRate
example issue here where logs include a replay_id but no replay is associated with the error or found in replays search
Expected Result
If a replay isn’t sampled and won’t be sent to Sentry, the associated error/log should not include a replay_id
Actual Result
Structured logs still contain a replay_id, even when the replay is skipped due to sampling. This creates confusion for users who try to search for the replay in Sentry but can’t find it.
Additional Context
Tip: React with 👍 to help prioritize this issue. Please use comments to provide useful context, avoiding +1 or me too, to help us triage it.
Thanks for reporting! I can see how this is confusing. Thing is right now, it's not super easy to check if the replay was sampled positively or negatively. After a quick check, we could probably only return an id here,
sentry-javascript/packages/replay-internal/src/replay.ts
Lines 723 to 725 in 6e8e561
if the session was sampled (or rather, return undefined if !sampled. Thoughts @AbhiPrasad, @chargome, @billyvg?
Not sure if this wouldn't interfere with manually started replays 🤔
I quickly checked this when replying and it seems like manually started replay sessions are started with sessionSampleRate: 1. Though this is just my naive assumption, maybe there's more to this that I'm not aware of.
I'd be open to adjust getSessionId to only run if sampled, but not sure if there are other consequences here.
I could move the logging related code into the replay integration, let me open up a PR to show this as an example.