Backend: Inject server-timing header to match initial loads with client-side telemetry (#94978)
feat: inject server-timing header to match initial loads with client-side telemetry Faro Web SDK can read the server-timing info and correlate the initial request with the client side telemetry gather from navigation timings.
This commit is contained in:
@@ -94,6 +94,14 @@ func RequestTracing(tracer tracing.Tracer) web.Middleware {
|
||||
), trace.WithSpanKind(trace.SpanKindServer))
|
||||
defer span.End()
|
||||
|
||||
// inject local root span context into the response via server-timing header
|
||||
// we're doing it this early so that we can capture the root span context
|
||||
// which is not available later-on.
|
||||
serverTimingValue := tracing.ServerTimingForSpan(span)
|
||||
if serverTimingValue != "" {
|
||||
w.Header().Set("server-timing", fmt.Sprintf("traceparent;desc=\"%s\"", serverTimingValue))
|
||||
}
|
||||
|
||||
req = req.WithContext(ctx)
|
||||
|
||||
// Ensure the response writer's status can be captured.
|
||||
|
||||
Reference in New Issue
Block a user