outpost: fix spans being sent without parent context
Signed-off-by: Jens Langhammer <jens.langhammer@beryju.org>
This commit is contained in:
parent
e751ce1220
commit
70d1e3a0cb
|
@ -47,7 +47,7 @@ func NewAPIController(akURL url.URL, token string) *APIController {
|
|||
config.Host = akURL.Host
|
||||
config.Scheme = akURL.Scheme
|
||||
config.HTTPClient = &http.Client{
|
||||
Transport: NewTracingTransport(GetTLSTransport()),
|
||||
Transport: NewTracingTransport(context.TODO(), GetTLSTransport()),
|
||||
}
|
||||
config.AddDefaultHeader("Authorization", fmt.Sprintf("Bearer %s", token))
|
||||
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package ak
|
||||
|
||||
import (
|
||||
"context"
|
||||
"net/http"
|
||||
|
||||
"github.com/getsentry/sentry-go"
|
||||
|
@ -8,14 +9,15 @@ import (
|
|||
|
||||
type tracingTransport struct {
|
||||
inner http.RoundTripper
|
||||
ctx context.Context
|
||||
}
|
||||
|
||||
func NewTracingTransport(inner http.RoundTripper) *tracingTransport {
|
||||
return &tracingTransport{inner}
|
||||
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(r.Context(), "authentik.go.http_request")
|
||||
span := sentry.StartSpan(tt.ctx, "authentik.go.http_request")
|
||||
span.SetTag("url", r.URL.String())
|
||||
span.SetTag("method", r.Method)
|
||||
defer span.Finish()
|
||||
|
|
|
@ -61,7 +61,7 @@ func NewFlowExecutor(ctx context.Context, flowSlug string, refConfig *api.Config
|
|||
config.UserAgent = constants.OutpostUserAgent()
|
||||
config.HTTPClient = &http.Client{
|
||||
Jar: jar,
|
||||
Transport: ak.NewTracingTransport(ak.GetTLSTransport()),
|
||||
Transport: ak.NewTracingTransport(ctx, ak.GetTLSTransport()),
|
||||
}
|
||||
apiClient := api.NewAPIClient(config)
|
||||
return &FlowExecutor{
|
||||
|
|
Reference in New Issue