diff --git a/src/github.com/matrix-org/dendrite/common/httpapi.go b/src/github.com/matrix-org/dendrite/common/httpapi.go index 1b8139717..67a2ac90e 100644 --- a/src/github.com/matrix-org/dendrite/common/httpapi.go +++ b/src/github.com/matrix-org/dendrite/common/httpapi.go @@ -32,6 +32,7 @@ func MakeExternalAPI(metricsName string, f func(*http.Request) util.JSONResponse withSpan := func(w http.ResponseWriter, req *http.Request) { span := opentracing.StartSpan(metricsName) defer span.Finish() + req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span)) h.ServeHTTP(w, req) } @@ -54,6 +55,7 @@ func MakeInternalAPI(metricsName string, f func(*http.Request) util.JSONResponse span = tracer.StartSpan(metricsName, ext.RPCServerOption(clientContext)) } defer span.Finish() + req = req.WithContext(opentracing.ContextWithSpan(req.Context(), span)) h.ServeHTTP(w, req) }