diff --git a/cmd/daemon/serve.go b/cmd/daemon/serve.go index c87a57725cff..853f0b13544a 100644 --- a/cmd/daemon/serve.go +++ b/cmd/daemon/serve.go @@ -92,6 +92,9 @@ func ServePublic(r driver.Registry, wg *sync.WaitGroup, cmd *cobra.Command, args n.Use(publicLogger) n.Use(x.HTTPLoaderContextMiddleware(r)) n.Use(sqa(ctx, cmd, r)) + if tracer := r.Tracer(ctx); tracer.IsLoaded() { + n.Use(tracer) + } n.Use(r.PrometheusManager()) router := x.NewRouterPublic() @@ -110,10 +113,6 @@ func ServePublic(r driver.Registry, wg *sync.WaitGroup, cmd *cobra.Command, args r.RegisterPublicRoutes(ctx, router) r.PrometheusManager().RegisterRouter(router.Router) - if tracer := r.Tracer(ctx); tracer.IsLoaded() { - n.Use(tracer) - } - var handler http.Handler = n options, enabled := r.Config(ctx).CORS("public") if enabled { diff --git a/driver/registry_default.go b/driver/registry_default.go index 47c94bd39f0e..4152bd1a3100 100644 --- a/driver/registry_default.go +++ b/driver/registry_default.go @@ -688,8 +688,13 @@ func (m *RegistryDefault) HTTPClient(ctx context.Context, opts ...httpx.Resilien opts = append(opts, httpx.ResilientClientWithLogger(m.Logger()), httpx.ResilientClientWithMaxRetry(2), - httpx.ResilientClientWithConnectionTimeout(30*time.Second), - ) + httpx.ResilientClientWithConnectionTimeout(30*time.Second)) + + tracer := m.Tracer(ctx) + if tracer.IsLoaded() { + opts = append(opts, httpx.ResilientClientWithTracer(tracer.Tracer())) + } + if m.Config(ctx).ClientHTTPNoPrivateIPRanges() { opts = append(opts, httpx.ResilientClientDisallowInternalIPs()) } diff --git a/go.mod b/go.mod index b7879a0d7a9f..cb87e5f3c34b 100644 --- a/go.mod +++ b/go.mod @@ -78,7 +78,7 @@ require ( github.com/ory/kratos-client-go v0.6.3-alpha.1 github.com/ory/mail/v3 v3.0.0 github.com/ory/nosurf v1.2.7 - github.com/ory/x v0.0.336 + github.com/ory/x v0.0.337 github.com/phayes/freeport v0.0.0-20180830031419-95f893ade6f2 github.com/pkg/errors v0.9.1 github.com/pquerna/otp v1.3.0 diff --git a/go.sum b/go.sum index 618af5f400bc..eb24e8037c63 100644 --- a/go.sum +++ b/go.sum @@ -1642,8 +1642,8 @@ github.com/ory/x v0.0.205/go.mod h1:A1s4iwmFIppRXZLF3J9GGWeY/HpREVm0Dk5z/787iek= github.com/ory/x v0.0.250/go.mod h1:jUJaVptu+geeqlb9SyQCogTKj5ztSDIF6APkhbKtwLc= github.com/ory/x v0.0.272/go.mod h1:1TTPgJGQutrhI2OnwdrTIHE9ITSf4MpzXFzA/ncTGRc= github.com/ory/x v0.0.288/go.mod h1:APpShLyJcVzKw1kTgrHI+j/L9YM+8BRjHlcYObc7C1U= -github.com/ory/x v0.0.336 h1:z2AHweTT3A7q+Euq6Kna8jz3wogvLl6eMo7dGuNeZvU= -github.com/ory/x v0.0.336/go.mod h1:VxITg5o/DfPfom76ni5FfFzP66Z+kLvJ/OATJxuT42c= +github.com/ory/x v0.0.337 h1:YDlmEA43NMJJxezVVAQoqXyyYl/ZZSh9+mA8JSbOECw= +github.com/ory/x v0.0.337/go.mod h1:VxITg5o/DfPfom76ni5FfFzP66Z+kLvJ/OATJxuT42c= github.com/pact-foundation/pact-go v1.0.4/go.mod h1:uExwJY4kCzNPcHRj+hCR/HBbOOIwwtUjcrb0b5/5kLM= github.com/parnurzeal/gorequest v0.2.15/go.mod h1:3Kh2QUMJoqw3icWAecsyzkpY7UzRfDhbRdTjtNwNiUE= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= diff --git a/selfservice/hook/web_hook.go b/selfservice/hook/web_hook.go index d51b314c586f..03476a8ac726 100644 --- a/selfservice/hook/web_hook.go +++ b/selfservice/hook/web_hook.go @@ -273,7 +273,7 @@ func (e *WebHook) execute(ctx context.Context, data *templateContext) error { body = bytes.NewReader(make([]byte, 0)) } - if err = doHttpCall(conf.Method, conf.URL, conf.Auth, body, httpClient); err != nil { + if err = doHttpCall(ctx, conf.Method, conf.URL, conf.Auth, body, httpClient); err != nil { return fmt.Errorf("failed to call web hook %w", err) } return nil @@ -317,8 +317,9 @@ func createBody(l *logrusx.Logger, templateURI string, data *templateContext, hc } } -func doHttpCall(method string, url string, as AuthStrategy, body io.Reader, hc *retryablehttp.Client) error { +func doHttpCall(ctx context.Context, method string, url string, as AuthStrategy, body io.Reader, hc *retryablehttp.Client) error { req, err := retryablehttp.NewRequest(method, url, body) + req = req.WithContext(ctx) if err != nil { return err }