This repository has been archived on 2024-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
authentik/internal/outpost/ak/tracing.go
Jens Langhammer 70d1e3a0cb outpost: fix spans being sent without parent context
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
2021-09-03 18:17:08 +02:00

26 lines
590 B
Go

package ak
import (
"context"
"net/http"
"github.com/getsentry/sentry-go"
)
type tracingTransport struct {
inner http.RoundTripper
ctx context.Context
}
func NewTracingTransport(ctx context.Context, inner http.RoundTripper) *tracingTransport {
return &tracingTransport{inner, ctx}
}
func (tt *tracingTransport) RoundTrip(r *http.Request) (*http.Response, error) {
span := sentry.StartSpan(tt.ctx, "authentik.go.http_request")
span.SetTag("url", r.URL.String())
span.SetTag("method", r.Method)
defer span.Finish()
return tt.inner.RoundTrip(r.WithContext(span.Context()))
}