feat(sentry): add error monitoring for router, worker, and dashboard#502
Merged
zbigniewsobiecki merged 1 commit intodevfrom Feb 23, 2026
Merged
feat(sentry): add error monitoring for router, worker, and dashboard#502zbigniewsobiecki merged 1 commit intodevfrom
zbigniewsobiecki merged 1 commit intodevfrom
Conversation
Integrate @sentry/node v10 across all three container types (router, worker, dashboard) using Node's --import flag for early SDK initialization. Core: - Add src/instrument.ts (module preload) and src/sentry.ts (no-op wrappers) - Wire Sentry captures into all Hono error handlers, webhook processing, worker lifecycle, watchdog timeouts, queue errors, and retry exhaustion - Forward SENTRY_* env vars from router to spawned worker containers Bug fixes found during review: - Fix tracesSampleRate=0 silently becoming 0.1 (|| vs nullish check) - Add Sentry flush before watchdog process.exit(1) to drain queued events - Remove redundant try/catch in router webhook handlers that swallowed queue failures (Redis down → 200 instead of 500), restoring correct HTTP semantics for webhook provider retries - Add Sentry capture to server mode's handleProcessingError (was log-only) Code quality: - Extract dispatchJob() from worker-entry main() to fix cognitive complexity lint warning (17 > 15) - Fix all import ordering and formatting issues Tests: - Add tests/unit/sentry.test.ts — no-op behavior, context propagation - Add tests/unit/instrument.test.ts — conditional init, tracesSampleRate=0 - Add Sentry flush assertion to lifecycle watchdog tests - Add handleProcessingError Sentry capture test to webhookHandlers Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@sentry/nodev10 across all three container types (router, worker, dashboard) using Node's--importflag for early SDK initializationsrc/instrument.ts(module preload) andsrc/sentry.ts(thin no-op wrappers that guard all calls behindSENTRY_DSN)SENTRY_*env vars from router to spawned worker containersBug fixes found during code review
tracesSampleRate=0silently became0.1(||treats 0 as falsy)!= nullcheck on raw env varprocess.exit(1)dropped queued Sentry events (no flush)await flush(3000)before exitapp.onError→ 500handleProcessingErrorhad no Sentry capturecaptureException--importflag to Dockerfile + captures in error handlerserver.tserror handler had no Sentry capturecaptureExceptionCode quality
dispatchJob()fromworker-entry.tsmain()to fix cognitive complexity lint warning (17 → well under 15)Files changed
New files:
src/instrument.ts,src/sentry.ts,tests/unit/instrument.test.ts,tests/unit/sentry.test.tsModified (source):
src/router/index.ts,src/router/worker-manager.ts,src/router/queue.ts,src/worker-entry.ts,src/agents/shared/lifecycle.ts,src/utils/lifecycle.ts,src/server.ts,src/server/webhookHandlers.ts,src/dashboard.ts,src/config/env.ts,src/config/retryConfig.ts,Dockerfile.dashboard,Dockerfile.router,Dockerfile.worker,CLAUDE.mdModified (tests):
tests/unit/utils/lifecycle.test.ts,tests/unit/server/webhookHandlers.test.tsTest plan
npm run lint— zero errorsnpm run typecheck— zero errorsnpm test— 2730 tests pass (165 files), including 22 new Sentry-specific testsSENTRY_TRACES_SAMPLE_RATE=0, verify tracing is disabled (not overridden to 0.1)SENTRY_DSNset, trigger a webhook error, verify event appears in Sentry🤖 Generated with Claude Code