fix(sentry): report correct HTTP path in traces
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)) +}