feat: remove superfluous sentry span handlers

This commit is contained in:
wpetit 2024-10-02 12:12:51 +02:00
parent ecacbb1cbd
commit 9bd1d0fbd7
3 changed files with 1 additions and 42 deletions

View File

@ -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)
}

View File

@ -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) {

View File

@ -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)
}