about summary refs log tree commit diff stats
path: root/internal/sentryhttp/http.go
diff options
context:
space:
mode:
authorAlan Pearce2025-01-19 01:19:15 +0100
committerAlan Pearce2025-01-19 01:19:15 +0100
commiteece88d32b1b613aba7ec2f11bcfeb10163616b1 (patch)
treefaee549b469409514bf43bd7657b4ae585888f2d /internal/sentryhttp/http.go
parentc7be08473e423ead4896aaa2b3355a08c4559145 (diff)
downloadsearchix-eece88d32b1b613aba7ec2f11bcfeb10163616b1.tar.lz
searchix-eece88d32b1b613aba7ec2f11bcfeb10163616b1.tar.zst
searchix-eece88d32b1b613aba7ec2f11bcfeb10163616b1.zip
fix(sentry): report correct HTTP path in traces
Diffstat (limited to 'internal/sentryhttp/http.go')
-rw-r--r--internal/sentryhttp/http.go29
1 files changed, 29 insertions, 0 deletions
diff --git a/internal/sentryhttp/http.go b/internal/sentryhttp/http.go
new file mode 100644
index 0000000..7897b81
--- /dev/null
+++ b/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))
+}