Skip to content

feat(core): Handle string sample rates #11305

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

Merged
merged 1 commit into from
Mar 27, 2024
Merged

Conversation

mydea
Copy link
Member

@mydea mydea commented Mar 27, 2024

If users pass e.g. sampleRate: process.env.SAMPLE_RATE, this will be somewhat silently ignored because we ignore non-number sample rates. This is a bit of a footgun.

So this PR changes this so that we actually accept such sample rates. In the process, I also removed the isNaN polyfill as this is not really needed anymore.

I also updated OTEL to use the same sampling function as core (to avoid this drifting apart), and am using this for sampleRate, tracesSampleRate and the replay sample rates now.

See e.g. #11262

@mydea mydea requested review from lforst, AbhiPrasad and s1gr1d March 27, 2024 11:12
@mydea mydea self-assigned this Mar 27, 2024

This comment was marked as off-topic.

Copy link
Contributor

github-actions bot commented Mar 27, 2024

size-limit report 📦

Path Size
@sentry/browser (incl. Tracing, Replay, Feedback) 80.45 KB (-0.11% 🔽)
@sentry/browser (incl. Tracing, Replay) 71.79 KB (-0.12% 🔽)
@sentry/browser (incl. Tracing, Replay with Canvas) 75.6 KB (-0.11% 🔽)
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 65.35 KB (-0.13% 🔽)
@sentry/browser (incl. Tracing) 36.62 KB (-0.28% 🔽)
@sentry/browser (incl. browserTracingIntegration) 36.62 KB (-0.28% 🔽)
@sentry/browser (incl. feedbackIntegration) 31.53 KB (+0.47% 🔺)
@sentry/browser (incl. feedbackModalIntegration) 31.63 KB (+0.41% 🔺)
@sentry/browser (incl. feedbackScreenshotIntegration) 31.64 KB (+0.41% 🔺)
@sentry/browser (incl. sendFeedback) 27.59 KB (+0.52% 🔺)
@sentry/browser 22.75 KB (+0.64% 🔺)
CDN Bundle (incl. Tracing, Replay, Feedback) 74.9 KB (-0.11% 🔽)
CDN Bundle (incl. Tracing, Replay) 69.73 KB (-0.1% 🔽)
CDN Bundle (incl. Tracing) 36.27 KB (-0.21% 🔽)
CDN Bundle 24.02 KB (+0.19% 🔺)
CDN Bundle (incl. Tracing, Replay) - uncompressed 218.79 KB (-0.15% 🔽)
CDN Bundle (incl. Tracing) - uncompressed 109.44 KB (-0.22% 🔽)
CDN Bundle - uncompressed 71.08 KB (+0.19% 🔺)
@sentry/react (incl. Tracing, Replay) 71.78 KB (-0.13% 🔽)
@sentry/react 22.78 KB (+0.65% 🔺)

If users pass e.g. `sampleRate: process.env.SAMPLE_RATE`, this will be somewhat silently ignored because we ignore non-number sample rates. This is a bit of a footgun.

So this PR changes this so that we actually accept such sample rates.
In the process, I also removed the `isNaN` polyfill as this is not really needed anymore.
@mydea mydea force-pushed the fn/string-sample-rates branch from b26b3e8 to c1041b6 Compare March 27, 2024 13:28
@mydea mydea merged commit ad02a79 into develop Mar 27, 2024
@mydea mydea deleted the fn/string-sample-rates branch March 27, 2024 13:54
cadesalaberry pushed a commit to cadesalaberry/sentry-javascript that referenced this pull request Apr 19, 2024
If users pass e.g. `sampleRate: process.env.SAMPLE_RATE`, this will be
somewhat silently ignored because we ignore non-number sample rates.
This is a bit of a footgun.

So this PR changes this so that we actually accept such sample rates. In
the process, I also removed the `isNaN` polyfill as this is not really
needed anymore.

I also updated OTEL to use the same sampling function as core (to avoid
this drifting apart), and am using this for `sampleRate`,
`tracesSampleRate` and the replay sample rates now.

See e.g. getsentry#11262
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.

2 participants