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

chore: improve sentry sampling #570

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

kanej
Copy link
Member

@kanej kanej commented May 8, 2024

Sample most traces as before (1 in development, 0.001 in production), but exclude the indexing trace, which won't be sampled.

Indexing happens once per session, and is being used to provide feature flag information. That info is significantly less useful if it is sampled.

The fine grained control is provided by swapping from a trace sampling rate to a trace sampling function, as described here: https://docs.sentry.io/platforms/javascript/guides/capacitor/configuration/sampling/#setting-a-sampling-function

Sample most traces as before (1 in development, 0.001 in production),
but exclude the `indexing` trace, which won't be sampled.

Indexing happens once per session, and is being used to provide feature
flag information. That info is significantly less useful if it is
sampled.
@github-actions github-actions bot added the status:ready This issue is ready to be worked on label May 8, 2024
@kanej kanej requested a review from alcuadrado May 8, 2024 22:37
Sentry.init({
dsn: this.dsn,
tracesSampleRate: serverState.env === "development" ? 1 : 0.001,
tracesSampler: ({ transactionContext: { name } }) => {
if (name === "indexing") {
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit suggestion:
I see we are using the raw indexing value in a few places already. I suggest exporting/reusing INDEXING_JOB_ID everywhere so that they don't go out of sync.

Sentry.init({
dsn: this.dsn,
tracesSampleRate: serverState.env === "development" ? 1 : 0.001,
tracesSampler: ({ transactionContext: { name } }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

this means we will no longer have sampling for both the user platform AND the 2 features flag status (as they are recorded within indexing). Is that correct?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes. The indexing event won't be sampled, as the feature flag status is recorded into this event, neither will the feature flag tags.
Put another way sampling will no longer obscure the indexing based recording of feature flags.

Copy link
Contributor

@OmarTawfik OmarTawfik left a comment

Choose a reason for hiding this comment

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

Wonderful fix!
Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status:ready This issue is ready to be worked on
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

None yet

2 participants