server: report HTTP handler panics to Sentry (closes #107)
check / check (push) Successful in 1m35s
check / check (push) Successful in 1m35s
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
This commit was merged in pull request #184.
This commit is contained in:
@@ -3,6 +3,8 @@ package server
|
||||
import (
|
||||
"net/http"
|
||||
"time"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
// RequestTimeout exports the handler execution budget applied by
|
||||
@@ -22,3 +24,15 @@ func SetListenPort(s *Server, port int) {
|
||||
func HTTPServerOf(s *Server) *http.Server {
|
||||
return s.httpServer
|
||||
}
|
||||
|
||||
// EnableSentry runs the Sentry setup that the start hook runs, without
|
||||
// starting the HTTP server.
|
||||
func EnableSentry(s *Server) error {
|
||||
return s.enableSentry()
|
||||
}
|
||||
|
||||
// RouterOf returns the router SetupRoutes built, so a test can add a
|
||||
// route that panics.
|
||||
func RouterOf(s *Server) *chi.Mux {
|
||||
return s.router
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user