Repository navigation
feat(observability): wire errors-only Sentry SDK to GlitchTip - #19
Merged
Merged
Conversation
Add the @sentry/node SDK in an errors-only configuration reporting to the self-hosted GlitchTip. No tracing, no profiling, no session replay, no app-log ingestion — default integrations capture errors and unhandled exceptions/rejections only. - src/instrument.ts: minimal Sentry.init gated on SENTRY_DSN (empty DSN => SDK no-op), environment from NODE_ENV (default "staging"), optional release from SENTRY_RELEASE, tracesSampleRate: 0. - src/server.ts: import "./instrument.js" as the very first line so the SDK patches before any app/framework module loads. - vitest.config.ts: exclude the bootstrap side-effect file from coverage (same category as src/server.ts). - .env.example / .env.production.example: document SENTRY_DSN and SENTRY_RELEASE (no secrets; DSN injected by infra in staging/prod). Per plans/server-2/briefs/sentry-wire.md (infrastructure Phase 18). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Afgan0r
marked this pull request as draft
June 14, 2026 16:59
…ored instrument.ts ran before `dotenv/config`, so Sentry.init read SENTRY_DSN before the .env file was loaded — a DSN configured the documented way (via .env, per .env.example) was undefined at init and the SDK silently no-op'd. Infra-injected (k8s Secret) env still worked. Import dotenv at the top of instrument.ts before Sentry.init; drop the now-redundant import in server.ts (ESM-cached, so env still loads before loadConfig). Co-Authored-By: Claude Opus 4.8 (1M context) <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.
Wires
@sentry/node(errors-only) so application errors reach the self-hosted GlitchTip. No tracing, no profiling, no log integrations.Change
src/instrument.ts(new) — minimalSentry.init:dsnfromSENTRY_DSN(empty → SDK no-op),environmentfromNODE_ENV(defaultstaging), optionalreleasefromSENTRY_RELEASE,tracesSampleRate: 0. Default integrations capture errors + unhandled exceptions/rejections. Readsprocess.envdirectly (documented) because it must run before the validated config loader — same exception the repo makes fordotenv/config.src/server.ts—import "./instrument.js"as the very first line (beforedotenv/configand all framework imports).vitest.config.ts— excludesrc/instrument.tsfrom coverage (bootstrap side-effect, likesrc/server.ts)..env.example/.env.production.example— documentSENTRY_DSN+SENTRY_RELEASE(placeholders).package.json/pnpm-lock.yaml— add@sentry/node.Notes
tsc --noEmit, 657 unit tests (78 files), frozen-lockfile consistent. Coverage + Postgres-testcontainer integration tests need Docker (unavailable in the sandbox) and fail identically on clean master — CI on this PR is the real signal; this change touches no DB/migration code.Left for ops
SENTRY_DSNin theserver-2-runtimek8s Secret (infra already injects it viaenvFrom; no infra change needed here).🤖 Generated with Claude Code