Skip to content

chore: reduce Sentry span sampling outside development#1475

Merged
brendan-kellam merged 3 commits into
mainfrom
brendan-kellam/sentry-event-sampling-SOU-1557
Jul 21, 2026
Merged

chore: reduce Sentry span sampling outside development#1475
brendan-kellam merged 3 commits into
mainfrom
brendan-kellam/sentry-event-sampling-SOU-1557

Conversation

@brendan-kellam

@brendan-kellam brendan-kellam commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Fixes SOU-1557

Summary

  • retain 100% Sentry span sampling in development
  • sample 10% of spans in the browser, Next.js server and edge runtimes, and backend worker in every other environment
  • leave Sentry error event sampling unchanged

Testing

  • yarn workspace @sourcebot/web exec eslint src/instrumentation-client.ts src/sentry.server.config.ts src/sentry.edge.config.ts
  • yarn workspace @sourcebot/backend exec tsc --noEmit
  • yarn 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.ts

Summary by CodeRabbit

  • Chores
    • Adjusted Sentry performance/error capture sampling to use 100% in development and 10% outside development.
    • Applied consistently across backend, web client, server, and edge Sentry initialization.
  • Documentation
    • Updated the changelog to reflect the environment-based sampling change.

@github-actions

This comment has been minimized.

@coderabbitai

coderabbitai Bot commented Jul 21, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Sentry 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.

Changes

Sentry sampling configuration

Layer / File(s) Summary
Apply environment-based sampling
packages/backend/src/instrument.ts, packages/web/src/instrumentation-client.ts, packages/web/src/sentry.edge.config.ts, packages/web/src/sentry.server.config.ts, CHANGELOG.md
Sentry uses a 1.0 tracesSampleRate in development and 0.1 otherwise across all initialization paths, and the changelog documents the change.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Possibly related PRs

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: lowering Sentry sampling to 10% outside development.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch brendan-kellam/sentry-event-sampling-SOU-1557

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread packages/backend/src/instrument.ts Outdated
// 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 5e991c4. Configure here.

@brendan-kellam brendan-kellam changed the title chore: reduce Sentry event sampling outside development chore: reduce Sentry span sampling outside development Jul 21, 2026
@brendan-kellam
brendan-kellam merged commit e1ce46b into main Jul 21, 2026
12 checks passed
@brendan-kellam
brendan-kellam deleted the brendan-kellam/sentry-event-sampling-SOU-1557 branch July 21, 2026 19:46

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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).

Fix All in Cursor

❌ 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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

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,

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

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.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit af8c811. Configure here.

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.

1 participant