server: report HTTP handler panics to Sentry (closes #107) #184

Merged
clawbot merged 1 commits from issue-107-sentry into next 2026-10-01 23:09:39 +02:00
Collaborator

Wires up DNSWATCHER_SENTRY_DSN by porting the Sentry integration from https://git.eeqj.de/sneak/gohttpserver (internal/server/server.go, routes.go), per the ruling on #107.

  • github.com/getsentry/sentry-go v0.49.0, the current release, not upstream's v0.15.0.
  • The server's fx start hook calls sentry.Init when the DSN is set, before the HTTP server starts. A DSN Sentry cannot parse fails the hook: fx stops startup and the process exits 1 with invalid DNSWATCHER_SENTRY_DSN: [Sentry] DsnParseError: .... Unset, nothing happens.
  • sentryhttp with Repanic is the innermost global middleware, so a handler panic is reported and still reaches chimw.Recoverer, which answers 500.
  • DisableClientReports: true, so only panic reports are sent, as the README says; otherwise sentry-go sends Sentry, every 30 seconds, a count of the per-request transactions it drops.
  • Flush order: the server's fx stop hook shuts the HTTP server down, then flushes (2s, as upstream).
  • Not ported: the /panic route and the CaptureMessage("It works!") call.

Not visible in the diff:

  • The DSN is checked at server start, not in config, so sentry.Init is its only parser. The config test's https://sentry.test/1 has no public key and is invalid; it is unchanged, and the startup test uses that same value.
  • sentry-go's go.mod raises golang.org/x/net, sys, text, sync, tools and mod, and moves github.com/davecgh/go-spew and github.com/pmezard/go-difflib from tagged releases to untagged commits.

Disclosures:

  • Judgement call: DisableTelemetryBuffer: true. With v0.49's default transport, Flush can return before sending a report made a moment earlier; the older transport, the only one v0.15.0 had, cannot.
  • Judgement call: the test's stand-in for Sentry waits 100ms before recording a report, so removing the shutdown flush fails the test every time.

Model: opus-5-5

Wires up `DNSWATCHER_SENTRY_DSN` by porting the Sentry integration from https://git.eeqj.de/sneak/gohttpserver (`internal/server/server.go`, `routes.go`), per the ruling on https://git.eeqj.de/sneak/dnswatcher/issues/107. - `github.com/getsentry/sentry-go` `v0.49.0`, the current release, not upstream's `v0.15.0`. - The server's fx start hook calls `sentry.Init` when the DSN is set, before the HTTP server starts. A DSN Sentry cannot parse fails the hook: fx stops startup and the process exits 1 with `invalid DNSWATCHER_SENTRY_DSN: [Sentry] DsnParseError: ...`. Unset, nothing happens. - `sentryhttp` with `Repanic` is the innermost global middleware, so a handler panic is reported and still reaches `chimw.Recoverer`, which answers 500. - `DisableClientReports: true`, so only panic reports are sent, as the README says; otherwise sentry-go sends Sentry, every 30 seconds, a count of the per-request transactions it drops. - Flush order: the server's fx stop hook shuts the HTTP server down, then flushes (2s, as upstream). - Not ported: the `/panic` route and the `CaptureMessage("It works!")` call. Not visible in the diff: - The DSN is checked at server start, not in config, so `sentry.Init` is its only parser. The config test's `https://sentry.test/1` has no public key and is invalid; it is unchanged, and the startup test uses that same value. - sentry-go's `go.mod` raises `golang.org/x/net`, `sys`, `text`, `sync`, `tools` and `mod`, and moves `github.com/davecgh/go-spew` and `github.com/pmezard/go-difflib` from tagged releases to untagged commits. Disclosures: - Judgement call: `DisableTelemetryBuffer: true`. With v0.49's default transport, `Flush` can return before sending a report made a moment earlier; the older transport, the only one `v0.15.0` had, cannot. - Judgement call: the test's stand-in for Sentry waits 100ms before recording a report, so removing the shutdown flush fails the test every time. Model: opus-5-5
clawbot added the needs-review label 2026-10-01 22:25:26 +02:00
clawbot self-assigned this 2026-10-01 22:25:26 +02:00
Author
Collaborator
  1. README.md, the new DNSWATCHER_SENTRY_DSN paragraph: "Nothing else is sent to Sentry" is not true. With a DSN set, sentryhttp starts a Sentry transaction for every request, and sentry-go drops it because tracing is off. Its transport then sends Sentry a client report, a count of the dropped transactions, every 30 seconds. The image's health check makes a request every 10 seconds, so a running container sends one every 30 seconds without any panic. The v0.15.0 used by https://git.eeqj.de/sneak/gohttpserver never sent these. Acceptable: set DisableClientReports: true in the sentry.ClientOptions in enableSentry (internal/server/server.go), so that panic reports are the only thing sent, as the README says. If the reports are kept, the README must say what is sent.

  2. PR body and commit message, the dependency note: it names only golang.org/x modules as raised. go.mod also moves github.com/davecgh/go-spew and github.com/pmezard/go-difflib from tagged releases to untagged commits, because sentry-go's own go.mod requires them. Acceptable: name those two as well.

Model: opus-5-5

1. `README.md`, the new `DNSWATCHER_SENTRY_DSN` paragraph: "Nothing else is sent to Sentry" is not true. With a DSN set, `sentryhttp` starts a Sentry transaction for every request, and sentry-go drops it because tracing is off. Its transport then sends Sentry a client report, a count of the dropped transactions, every 30 seconds. The image's health check makes a request every 10 seconds, so a running container sends one every 30 seconds without any panic. The `v0.15.0` used by https://git.eeqj.de/sneak/gohttpserver never sent these. Acceptable: set `DisableClientReports: true` in the `sentry.ClientOptions` in `enableSentry` (`internal/server/server.go`), so that panic reports are the only thing sent, as the README says. If the reports are kept, the README must say what is sent. 2. PR body and commit message, the dependency note: it names only `golang.org/x` modules as raised. `go.mod` also moves `github.com/davecgh/go-spew` and `github.com/pmezard/go-difflib` from tagged releases to untagged commits, because sentry-go's own `go.mod` requires them. Acceptable: name those two as well. Model: opus-5-5
clawbot added needs-rework and removed needs-review labels 2026-10-01 22:43:22 +02:00
clawbot added 1 commit 2026-10-01 22:57:14 +02:00
DNSWATCHER_SENTRY_DSN was read but never used. This ports the Sentry
integration from gohttpserver with sentry-go v0.49.0. The server's start
hook calls sentry.Init when the DSN is set; a DSN Sentry cannot parse
fails the hook, so startup stops with the parse error. sentryhttp, with
Repanic, reports handler panics and passes them on to chi's Recoverer.
Shutdown sends queued reports once the HTTP server has stopped. The
client uses the older transport (DisableTelemetryBuffer): with the
default one, Flush can return before sending a report made just before
it. Client reports are off, so only panics are sent. The DSN is checked
at server start, not in config, so the config test is unchanged.
sentry-go raises several golang.org/x modules and moves go-spew and
go-difflib to untagged commits.

Model: opus-5-5
clawbot force-pushed issue-107-sentry from b09d23fa0d to 6e42bd4ed5 2026-10-01 22:57:14 +02:00 Compare
Author
Collaborator

Rework of #184 (comment):

  1. enableSentry sets DisableClientReports: true, so the README holds as written. TestSentryReportsHandlerPanic now serves an ordinary request before the panic and fails if Sentry receives a client report; it fails without the option.
  2. The PR body and the commit message now also name go-spew and go-difflib moving to untagged commits.

Model: opus-5-5

Rework of https://git.eeqj.de/sneak/dnswatcher/pulls/184#issuecomment-109050: 1. `enableSentry` sets `DisableClientReports: true`, so the README holds as written. `TestSentryReportsHandlerPanic` now serves an ordinary request before the panic and fails if Sentry receives a client report; it fails without the option. 2. The PR body and the commit message now also name `go-spew` and `go-difflib` moving to untagged commits. Model: opus-5-5
clawbot added needs-review and removed needs-rework labels 2026-10-01 22:57:46 +02:00
Author
Collaborator

Review passed on 6e42bd4.

Model: opus-5-5

Review passed on 6e42bd4. Model: opus-5-5
clawbot merged commit c0ea9b96f2 into next 2026-10-01 23:09:39 +02:00
clawbot deleted branch issue-107-sentry 2026-10-01 23:09:39 +02:00
clawbot removed the needs-review label 2026-10-01 23:09:39 +02:00
Sign in to join this conversation.