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): Move sample rate tags into event context #6659

Merged
merged 5 commits into from
Jan 31, 2023

Conversation

billyvg
Copy link
Member

@billyvg billyvg commented Jan 4, 2023

Move sample rate from tags into context as that is the more appropriate location for this type of data. This data is more for us to collect to debug rather than having as a top level field on the replay event.

@billyvg billyvg changed the base branch from master to feat-replays-add-replay-type-to-event January 4, 2023 22:04
@billyvg billyvg changed the title feat replays move sample rate tags to event feat(replay): Move sample rate tags into replay_event Jan 4, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Jan 4, 2023

size-limit report 📦

Path Size
@sentry/browser - ES5 CDN Bundle (gzipped + minified) 19.83 KB (-0.01% 🔽)
@sentry/browser - ES5 CDN Bundle (minified) 61.48 KB (0%)
@sentry/browser - ES6 CDN Bundle (gzipped + minified) 18.5 KB (-0.01% 🔽)
@sentry/browser - ES6 CDN Bundle (minified) 54.79 KB (0%)
@sentry/browser - Webpack (gzipped + minified) 20.22 KB (0%)
@sentry/browser - Webpack (minified) 66.19 KB (0%)
@sentry/react - Webpack (gzipped + minified) 20.25 KB (0%)
@sentry/nextjs Client - Webpack (gzipped + minified) 47.54 KB (0%)
@sentry/browser + @sentry/tracing - ES5 CDN Bundle (gzipped + minified) 26.75 KB (-0.01% 🔽)
@sentry/browser + @sentry/tracing - ES6 CDN Bundle (gzipped + minified) 25.03 KB (-0.01% 🔽)
@sentry/replay ES6 CDN Bundle (gzipped + minified) 43.7 KB (+0.04% 🔺)
@sentry/replay - Webpack (gzipped + minified) 38.48 KB (+0.06% 🔺)
@sentry/browser + @sentry/tracing + @sentry/replay - ES6 CDN Bundle (gzipped + minified) 61.03 KB (+0.04% 🔺)

Base automatically changed from feat-replays-add-replay-type-to-event to master January 6, 2023 15:15
@billyvg billyvg force-pushed the feat-replays-move-sample-rate-tags-to-event branch from c6a48f2 to cc14603 Compare January 18, 2023 15:48
@billyvg billyvg marked this pull request as ready for review January 18, 2023 22:16
@billyvg billyvg requested review from mydea and Lms24 January 18, 2023 22:16
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

I'm wondering if there's a specific reason to set the sample rates as "top-level" fields rather than e.g. storing them in event.contexts.replay for example? Does it have something to do with contexts being hard to query for data analysis?
Just asking because usually we put stuff into contexts when collecting user options or additional information that's relevant for us to gather insights rather than relevant for the actual event.
Not saying this has to be changed, just curious ;)

@billyvg
Copy link
Member Author

billyvg commented Jan 19, 2023

Ah didn't realize that. Storing in context makes more sense then. What's the best way to set context while we are preparing the event?

@Lms24
Copy link
Member

Lms24 commented Jan 19, 2023

I think we have two options:

  1. Use the SDK to set the context. I think this is what we want to do eventually anyway, as outlined in Modify Sentry SDK to have a "replay" context, add replay_id to this context for transactions and errors #6741. So for example, when setupOnce() is called, we could call getCurrentHub().setContext('replay', {...}) and set the rates there. This however, will add this context to all events, including errors and transactions. I think relay-wise this is fine; just something we should keep in mind.

  2. Alternatively, we can just append the context in prepareReplayEvent. This doesn't exclude doing option 1 in the future so it might be a good place to start. Plus, it'll only apply the fields to replay events. Something along these lines

  preparedEvent.contexts = {
    ...preparedEvent.contexts,
    replay: {
      ...(preparedEvent.contexts && preparedEvent.contexts.replay),
      replaysOnErrorSampleRate: options.replaysOnErrorSampleRate
      replaysSessionSampleRate: options.replaysSessionSampleRate
    }
  }

wdyt?

@billyvg
Copy link
Member Author

billyvg commented Jan 24, 2023

I like the second option for now so that we're not attaching replay context to other events.

@billyvg billyvg force-pushed the feat-replays-move-sample-rate-tags-to-event branch from 3103672 to 7d9b23e Compare January 25, 2023 16:25
@billyvg billyvg force-pushed the feat-replays-move-sample-rate-tags-to-event branch from 12b6379 to af12c6f Compare January 26, 2023 15:29
@billyvg billyvg changed the title feat(replay): Move sample rate tags into replay_event feat(replay): Move sample rate tags into event context Jan 26, 2023
@billyvg billyvg requested a review from Lms24 January 26, 2023 17:46
Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice!

@billyvg billyvg merged commit a6c6b2a into master Jan 31, 2023
@billyvg billyvg deleted the feat-replays-move-sample-rate-tags-to-event branch January 31, 2023 15:00
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.

None yet

3 participants