Report handler panics to Sentry when SENTRY_DSN is set (closes #95) #107

Merged
clawbot merged 1 commits from issue-95-sentry into next 2026-10-04 05:57:03 +02:00
Collaborator

Closes #95.

With SENTRY_DSN set, the server initialises sentry-go with the release netwatch-server- followed by its version, and adds the sentryhttp middleware with Repanic: true: a panic in a handler is reported to that Sentry project, and the panic recovery still answers 500. On shutdown it waits up to 2 seconds for Sentry to finish sending. A DSN Sentry refuses stops the start with an error naming SENTRY_DSN. With it empty, Sentry is never set up. Both READMEs list the setting.

What the diff does not show:

  • sentry.Init sets Sentry's client for the whole process, so TestSentry covers the empty and the set case in one test and unsets the client when it ends.
  • TestSentry waits up to 5 seconds for the local stand-in for Sentry to receive the report instead of calling sentry.Flush: a flush right after the panic can return before sentry-go's own goroutine has queued the report.
  • The test's panicking route is added through Router() in export_test.go; the server itself has no such route.
  • sentry-go was added through make tidy from #45.

Disclosures:

  • Judgement call: the Sentry middleware is the last router-wide middleware, after the timeout, as the conventions order it; the metrics middleware stays on the matched routes, where #103 put it, so it now runs inside the Sentry middleware instead of before it.
  • Unverified: delivery to a real Sentry project over HTTPS; the tests use a local stand-in.

Model: opus-5-5

Closes https://git.eeqj.de/sneak/netwatch/issues/95. With `SENTRY_DSN` set, the server initialises `sentry-go` with the release `netwatch-server-` followed by its version, and adds the `sentryhttp` middleware with `Repanic: true`: a panic in a handler is reported to that Sentry project, and the panic recovery still answers 500. On shutdown it waits up to 2 seconds for Sentry to finish sending. A DSN Sentry refuses stops the start with an error naming `SENTRY_DSN`. With it empty, Sentry is never set up. Both READMEs list the setting. What the diff does not show: - `sentry.Init` sets Sentry's client for the whole process, so `TestSentry` covers the empty and the set case in one test and unsets the client when it ends. - `TestSentry` waits up to 5 seconds for the local stand-in for Sentry to receive the report instead of calling `sentry.Flush`: a flush right after the panic can return before `sentry-go`'s own goroutine has queued the report. - The test's panicking route is added through `Router()` in `export_test.go`; the server itself has no such route. - `sentry-go` was added through `make tidy` from https://git.eeqj.de/sneak/netwatch/issues/45. Disclosures: - Judgement call: the Sentry middleware is the last router-wide middleware, after the timeout, as the conventions order it; the metrics middleware stays on the matched routes, where https://git.eeqj.de/sneak/netwatch/pulls/103 put it, so it now runs inside the Sentry middleware instead of before it. - Unverified: delivery to a real Sentry project over HTTPS; the tests use a local stand-in. Model: opus-5-5
clawbot added the needs-review label 2026-10-04 05:38:54 +02:00
clawbot self-assigned this 2026-10-04 05:38:55 +02:00
clawbot added 1 commit 2026-10-04 05:38:55 +02:00
With SENTRY_DSN set, the server initialises sentry-go with the release
netwatch-server-<version>, adds the sentryhttp middleware with Repanic
as the last router-wide middleware, after the timeout, and flushes
Sentry for 2 seconds on shutdown. A DSN Sentry refuses stops the start
with an error naming SENTRY_DSN. With it empty, nothing is set up.

The metrics middleware stays on the matched routes only, so it runs
inside the Sentry middleware rather than before it.

Model: opus-5-5
Author
Collaborator

PASS: with SENTRY_DSN set, Sentry starts under the release netwatch-server- plus the version, sentryhttp with Repanic: true is the last router-wide middleware as the conventions order it, shutdown waits up to 2 seconds for Sentry, and a refused DSN stops the start naming SENTRY_DSN; with it empty nothing is set up and the container sends nothing out; the test, both READMEs and TODO.md meet the definition of done in #95.

Model: opus-5-5

PASS: with `SENTRY_DSN` set, Sentry starts under the release `netwatch-server-` plus the version, `sentryhttp` with `Repanic: true` is the last router-wide middleware as the conventions order it, shutdown waits up to 2 seconds for Sentry, and a refused DSN stops the start naming `SENTRY_DSN`; with it empty nothing is set up and the container sends nothing out; the test, both READMEs and `TODO.md` meet the definition of done in https://git.eeqj.de/sneak/netwatch/issues/95. Model: opus-5-5
clawbot added needs-checks and removed needs-review labels 2026-10-04 05:53:58 +02:00
clawbot merged commit dc2d240725 into next 2026-10-04 05:57:03 +02:00
clawbot deleted branch issue-95-sentry 2026-10-04 05:57:03 +02:00
Sign in to join this conversation.
No Reviewers
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/netwatch#107