fix(logger): forward error-level logs to Sentry#505
Open
TerrifiedBug wants to merge 1 commit into
Open
Conversation
errorLog previously wrote only to stderr, so the many catch sites that report failures through it (scheduler init, leader election, backup and rollback failures, etc.) were invisible to Sentry — error tracking showed green while background work silently failed. errorLog now forwards to Sentry.captureException when an Error is present (directly, or wrapped under error/err/cause/exception), tagged with the log tag and carrying the message. It is a no-op when Sentry has no active client, so the test suite and DSN-less self-host deployments are unaffected. Adds logger-sentry.test.ts covering the forward, nested-error extraction, the no-client no-op, the non-Error no-op, and tag sanitisation.
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.
Problem
errorLogwrote only tostderr. Every catch site that reports a failure through it — scheduler initialisation, leader election, backup/rollback failures, KMS warm-up, and ~hundreds of others — never reached Sentry. Error tracking showed green while background work silently failed, so real incidents went undetected.Found during a code-quality review (see
review/arch__core.md; top-scored quick-win inreview/BACKLOG.md).Change
errorLognow forwards toSentry.captureExceptionwhen an Error object is present — either passed directly asdata, or wrapped undererror/err/cause/exception. The event is tagged with the log tag and carries the original message.Sentry.getClient()is falsy): the test suite and self-host deployments without a configured DSN are completely unaffected — no behaviour change, no new console output.Error(with a stack), so it does not flood Sentry with message-only logs.Tests
src/lib/__tests__/logger-sentry.test.tscovers: direct-Error forward, nested-error extraction, the no-client no-op, the non-Error no-op, and tag CR/LF sanitisation.vitest runlogger suites: 28 passedeslinton changed files: 0 errors