feat: remove superfluous sentry span handlers
This commit is contained in:
parent
ecacbb1cbd
commit
9bd1d0fbd7
|
@ -8,7 +8,6 @@ import (
|
||||||
"forge.cadoles.com/Cadoles/go-proxy"
|
"forge.cadoles.com/Cadoles/go-proxy"
|
||||||
"forge.cadoles.com/Cadoles/go-proxy/wildcard"
|
"forge.cadoles.com/Cadoles/go-proxy/wildcard"
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/cache"
|
"forge.cadoles.com/cadoles/bouncer/internal/cache"
|
||||||
bouncersentry "forge.cadoles.com/cadoles/bouncer/internal/sentry"
|
|
||||||
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
"forge.cadoles.com/cadoles/bouncer/internal/store"
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
|
@ -259,7 +258,6 @@ func (d *Director) Middleware() proxy.Middleware {
|
||||||
}
|
}
|
||||||
|
|
||||||
handler := createMiddlewareChain(next, httpMiddlewares)
|
handler := createMiddlewareChain(next, httpMiddlewares)
|
||||||
handler = bouncersentry.SpanHandler(handler, "director.proxy")
|
|
||||||
|
|
||||||
handler.ServeHTTP(w, r)
|
handler.ServeHTTP(w, r)
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||||
"gitlab.com/wpetit/goweb/logger"
|
"gitlab.com/wpetit/goweb/logger"
|
||||||
|
|
||||||
bouncersentry "forge.cadoles.com/cadoles/bouncer/internal/sentry"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
type Server struct {
|
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)),
|
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) {
|
if err := http.Serve(listener, router); err != nil && !errors.Is(err, net.ErrClosed) {
|
||||||
|
|
|
@ -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)
|
|
||||||
}
|
|
Loading…
Reference in New Issue