chore: reduce Sentry span sampling outside development#1475
Conversation
This comment has been minimized.
This comment has been minimized.
WalkthroughSentry initialization now uses a full tracing sample rate in development and a 10% rate elsewhere across backend, client, edge, and server runtimes. The changelog records this configuration change. ChangesSentry sampling configuration
Estimated code review effort: 1 (Trivial) | ~5 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
| // to the version for builds that don't pass a commit SHA. | ||
| release: env.NEXT_PUBLIC_BUILD_COMMIT_SHA ?? SOURCEBOT_VERSION, | ||
| environment: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, | ||
| sampleRate: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, |
There was a problem hiding this comment.
Dev sampling gate never matches
Medium Severity
The Sentry sampleRate in development environments defaults to 0.1 instead of 1.0. This occurs because the backend's Sentry configuration compares NEXT_PUBLIC_SENTRY_ENVIRONMENT to 'development', while the .env.development file sets it to 'dev', preventing full error capture.
Reviewed by Cursor Bugbot for commit 5e991c4. Configure here.
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using high effort and found 2 potential issues.
There are 3 total unresolved issues (including 1 from previous review).
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit af8c811. Configure here.
| Sentry.browserProfilingIntegration(), | ||
| ], | ||
| tracesSampleRate: 1.0, | ||
| tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, |
There was a problem hiding this comment.
Wrong Sentry sampling option
High Severity
The change intended to sample Sentry error events at 10% outside development. Instead, tracesSampleRate was modified, leaving error capture at 100%. This samples web traces and associated profiling at 10% (instead of 100%) and newly enables backend performance tracing.
Reviewed by Cursor Bugbot for commit af8c811. Configure here.
| Sentry.browserProfilingIntegration(), | ||
| ], | ||
| tracesSampleRate: 1.0, | ||
| tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, |
There was a problem hiding this comment.
Dev sampling env mismatch
Medium Severity
The tracesSampleRate condition expects NEXT_PUBLIC_SENTRY_ENVIRONMENT to be 'development' for full sampling. The .env.development example uses 'dev', which means development environments will get a reduced sampling rate (0.1) instead of 1.0.
Reviewed by Cursor Bugbot for commit af8c811. Configure here.


Fixes SOU-1557
Summary
Testing
yarn workspace @sourcebot/web exec eslint src/instrumentation-client.ts src/sentry.server.config.ts src/sentry.edge.config.tsyarn workspace @sourcebot/backend exec tsc --noEmityarn workspace @sourcebot/web exec tsc --noEmit --skipLibCheck --target es2022 --module esnext --moduleResolution bundler src/instrumentation-client.ts src/sentry.edge.config.ts src/sentry.server.config.tsSummary by CodeRabbit