From 9bd1d0fbd72915474a302de5e418a3e67e1441ea Mon Sep 17 00:00:00 2001 From: William Petit Date: Wed, 2 Oct 2024 12:12:51 +0200 Subject: [PATCH] feat: remove superfluous sentry span handlers --- internal/proxy/director/director.go | 2 -- internal/proxy/server.go | 4 +--- internal/sentry/sentry.go | 37 ----------------------------- 3 files changed, 1 insertion(+), 42 deletions(-) delete mode 100644 internal/sentry/sentry.go diff --git a/internal/proxy/director/director.go b/internal/proxy/director/director.go index fb1c6c1..7ebba03 100644 --- a/internal/proxy/director/director.go +++ b/internal/proxy/director/director.go @@ -8,7 +8,6 @@ import ( "forge.cadoles.com/Cadoles/go-proxy" "forge.cadoles.com/Cadoles/go-proxy/wildcard" "forge.cadoles.com/cadoles/bouncer/internal/cache" - bouncersentry "forge.cadoles.com/cadoles/bouncer/internal/sentry" "forge.cadoles.com/cadoles/bouncer/internal/store" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" @@ -259,7 +258,6 @@ func (d *Director) Middleware() proxy.Middleware { } handler := createMiddlewareChain(next, httpMiddlewares) - handler = bouncersentry.SpanHandler(handler, "director.proxy") handler.ServeHTTP(w, r) } diff --git a/internal/proxy/server.go b/internal/proxy/server.go index 84534ec..aca2c48 100644 --- a/internal/proxy/server.go +++ b/internal/proxy/server.go @@ -32,8 +32,6 @@ import ( "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus/promhttp" "gitlab.com/wpetit/goweb/logger" - - bouncersentry "forge.cadoles.com/cadoles/bouncer/internal/sentry" ) type Server struct { @@ -197,7 +195,7 @@ func (s *Server) run(parentCtx context.Context, addrs chan net.Addr, errs chan e proxy.WithDefaultHandler(http.HandlerFunc(s.handleDefault)), ) - r.Handle("/*", bouncersentry.SpanHandler(handler, "http.proxy")) + r.Handle("/*", handler) }) if err := http.Serve(listener, router); err != nil && !errors.Is(err, net.ErrClosed) { diff --git a/internal/sentry/sentry.go b/internal/sentry/sentry.go deleted file mode 100644 index 07ddd3e..0000000 --- a/internal/sentry/sentry.go +++ /dev/null @@ -1,37 +0,0 @@ -package sentry - -import ( - "net/http" - - "github.com/getsentry/sentry-go" -) - -func SpanHandler(handler http.Handler, name string) http.Handler { - fn := func(w http.ResponseWriter, r *http.Request) { - ctx := r.Context() - - hub := sentry.GetHubFromContext(ctx) - if hub == nil { - hub = sentry.CurrentHub().Clone() - ctx = sentry.SetHubOnContext(ctx, hub) - } - - options := []sentry.SpanOption{ - sentry.WithOpName(name), - sentry.ContinueFromRequest(r), - sentry.WithTransactionSource(sentry.SourceURL), - } - - span := sentry.StartSpan(ctx, - name, - options..., - ) - defer span.Finish() - - r = r.WithContext(span.Context()) - - handler.ServeHTTP(w, r) - } - - return http.HandlerFunc(fn) -}