Set the span in the request context

This commit is contained in:
Mark Haines 2017-09-28 14:42:24 +01:00
parent 7fdc8c2bdc
commit d35dd8b0d9

View file

@ -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)
}