all repos — searchix @ eece88d32b1b613aba7ec2f11bcfeb10163616b1

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix(sentry): report correct HTTP path in traces

Alan Pearce
commit

eece88d32b1b613aba7ec2f11bcfeb10163616b1

parent

c7be08473e423ead4896aaa2b3355a08c4559145

1 file changed, 29 insertions(+), 0 deletions(-)

changed files
A internal/sentryhttp/http.go
@@ -0,0 +1,29 @@
+package sentryhttp + +import ( + "net/http" + + sentryhttp "github.com/getsentry/sentry-go/http" +) + +type ServeMux struct { + sentryHandler *sentryhttp.Handler + *http.ServeMux +} + +func NewServeMux() *ServeMux { + return &ServeMux{ + sentryHandler: sentryhttp.New(sentryhttp.Options{ + Repanic: true, + }), + ServeMux: http.NewServeMux(), + } +} + +func (sm *ServeMux) Handle(pattern string, handler http.Handler) { + sm.ServeMux.Handle(pattern, sm.sentryHandler.Handle(handler)) +} + +func (sm *ServeMux) HandleFunc(pattern string, handler http.HandlerFunc) { + sm.ServeMux.HandleFunc(pattern, sm.sentryHandler.HandleFunc(handler)) +}