Skip to content

feat(observability): wire errors-only Sentry SDK to GlitchTip - #19

Merged
Afgan0r merged 2 commits into
masterfrom
feat/sentry-errors-only
Jun 14, 2026
Merged

Afgan0r merged 2 commits into
masterfrom
feat/sentry-errors-only

Conversation

@Afgan0r

@Afgan0r Afgan0r commented Jun 14, 2026

Copy link
Copy Markdown
Contributor

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) — minimal Sentry.init: dsn from SENTRY_DSN (empty → SDK no-op), environment from NODE_ENV (default staging), optional release from SENTRY_RELEASE, tracesSampleRate: 0. Default integrations capture errors + unhandled exceptions/rejections. Reads process.env directly (documented) because it must run before the validated config loader — same exception the repo makes for dotenv/config.
  • src/server.ts — import "./instrument.js" as the very first line (before dotenv/config and all framework imports).
  • vitest.config.ts — exclude src/instrument.ts from coverage (bootstrap side-effect, like src/server.ts).
  • .env.example / .env.production.example — document SENTRY_DSN + SENTRY_RELEASE (placeholders).
  • package.json / pnpm-lock.yaml — add @sentry/node.

Notes

  • Repo is Fastify + TypeBox (not Express/zod); errors-only wiring touches no schema/framework code.
  • Local verify green: prettier, eslint, 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.
  • The brief's forced-error smoke test was intentionally not committed (throwaway, needs a live DSN).

Left for ops

  • Provide SENTRY_DSN in the server-2-runtime k8s Secret (infra already injects it via envFrom; no infra change needed here).

🤖 Generated with Claude Code

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
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>
@Afgan0r
Afgan0r marked this pull request as ready for review June 14, 2026 17:21
@Afgan0r
Afgan0r merged commit ef5a625 into master Jun 14, 2026
3 checks passed
@Afgan0r
Afgan0r deleted the feat/sentry-errors-only branch June 14, 2026 17:27
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