From 2252588c1dab9b7500b4f1c08d421c3aba3780b4 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 21 Jul 2026 15:35:37 -0400 Subject: [PATCH 1/3] chore: reduce Sentry event sampling outside development --- packages/backend/src/instrument.ts | 1 + packages/web/src/instrumentation-client.ts | 1 + packages/web/src/sentry.edge.config.ts | 1 + packages/web/src/sentry.server.config.ts | 1 + 4 files changed, 4 insertions(+) diff --git a/packages/backend/src/instrument.ts b/packages/backend/src/instrument.ts index 87866b378..266afca36 100644 --- a/packages/backend/src/instrument.ts +++ b/packages/backend/src/instrument.ts @@ -12,6 +12,7 @@ if (!!env.NEXT_PUBLIC_SENTRY_BACKEND_DSN && !!env.NEXT_PUBLIC_SENTRY_ENVIRONMENT // 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, }); } else { logger.debug("Sentry was not initialized"); diff --git a/packages/web/src/instrumentation-client.ts b/packages/web/src/instrumentation-client.ts index fb0ff0171..3f4ed9ee1 100644 --- a/packages/web/src/instrumentation-client.ts +++ b/packages/web/src/instrumentation-client.ts @@ -12,6 +12,7 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, + sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, integrations: [ Sentry.browserProfilingIntegration(), ], diff --git a/packages/web/src/sentry.edge.config.ts b/packages/web/src/sentry.edge.config.ts index 77866181f..15418938d 100644 --- a/packages/web/src/sentry.edge.config.ts +++ b/packages/web/src/sentry.edge.config.ts @@ -9,6 +9,7 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, + sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, tracesSampleRate: 1.0, diff --git a/packages/web/src/sentry.server.config.ts b/packages/web/src/sentry.server.config.ts index cd7d6b98d..f2b97fc0f 100644 --- a/packages/web/src/sentry.server.config.ts +++ b/packages/web/src/sentry.server.config.ts @@ -12,6 +12,7 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, + sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, integrations: [ nodeProfilingIntegration(), ], From 5e991c406c4646b77489e15a9535c6da9f1a2660 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 21 Jul 2026 15:36:07 -0400 Subject: [PATCH 2/3] chore: update changelog for PR 1475 --- CHANGELOG.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ce01f93fa..dfc99046c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Changed +- Reduced Sentry error event sampling to 10% outside development. [#1475](https://github.com/sourcebot-dev/sourcebot/pull/1475) + ## [5.1.3] - 2026-07-20 ### Added From af8c811e015f156e723033d180d6865e925d6af4 Mon Sep 17 00:00:00 2001 From: Brendan Kellam Date: Tue, 21 Jul 2026 15:43:09 -0400 Subject: [PATCH 3/3] fix: sample Sentry spans instead of errors --- CHANGELOG.md | 2 +- packages/backend/src/instrument.ts | 2 +- packages/web/src/instrumentation-client.ts | 3 +-- packages/web/src/sentry.edge.config.ts | 3 +-- packages/web/src/sentry.server.config.ts | 3 +-- 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index dfc99046c..e9a6091ac 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,7 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] ### Changed -- Reduced Sentry error event sampling to 10% outside development. [#1475](https://github.com/sourcebot-dev/sourcebot/pull/1475) +- Reduced Sentry span sampling to 10% outside development. [#1475](https://github.com/sourcebot-dev/sourcebot/pull/1475) ## [5.1.3] - 2026-07-20 diff --git a/packages/backend/src/instrument.ts b/packages/backend/src/instrument.ts index 266afca36..8b0beccac 100644 --- a/packages/backend/src/instrument.ts +++ b/packages/backend/src/instrument.ts @@ -12,7 +12,7 @@ if (!!env.NEXT_PUBLIC_SENTRY_BACKEND_DSN && !!env.NEXT_PUBLIC_SENTRY_ENVIRONMENT // 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, + tracesSampleRate: env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, }); } else { logger.debug("Sentry was not initialized"); diff --git a/packages/web/src/instrumentation-client.ts b/packages/web/src/instrumentation-client.ts index 3f4ed9ee1..7bcbc385f 100644 --- a/packages/web/src/instrumentation-client.ts +++ b/packages/web/src/instrumentation-client.ts @@ -12,11 +12,10 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, - sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, integrations: [ Sentry.browserProfilingIntegration(), ], - tracesSampleRate: 1.0, + tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, // Evaluated once per `Sentry.init()`, i.e. once per page load. profileSessionSampleRate: 1.0, // Profile only while a sampled root span is active, rather than continuously. diff --git a/packages/web/src/sentry.edge.config.ts b/packages/web/src/sentry.edge.config.ts index 15418938d..05c897ac1 100644 --- a/packages/web/src/sentry.edge.config.ts +++ b/packages/web/src/sentry.edge.config.ts @@ -9,9 +9,8 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, - sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, - tracesSampleRate: 1.0, + tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, // Setting this option to true will print useful information to the console while you're setting up Sentry. debug: false, diff --git a/packages/web/src/sentry.server.config.ts b/packages/web/src/sentry.server.config.ts index f2b97fc0f..6ba395674 100644 --- a/packages/web/src/sentry.server.config.ts +++ b/packages/web/src/sentry.server.config.ts @@ -12,11 +12,10 @@ if (!!process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN && !!process.env.NEXT_PUBLIC_SEN Sentry.init({ dsn: process.env.NEXT_PUBLIC_SENTRY_WEBAPP_DSN, environment: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT, - sampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, integrations: [ nodeProfilingIntegration(), ], - tracesSampleRate: 1.0, + tracesSampleRate: process.env.NEXT_PUBLIC_SENTRY_ENVIRONMENT === 'development' ? 1.0 : 0.1, // Evaluated once per `Sentry.init()`, i.e. once per server process. profileSessionSampleRate: 1.0, // Profile only while a sampled root span is active, rather than continuously.