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:
Cedric Ziel
2024-11-19 10:01:58 +02:00
committed by GitHub
parent 2364299a8c
commit 89e7e25b60
2 changed files with 17 additions and 0 deletions
+9
View File
@@ -381,6 +381,15 @@ func TraceIDFromContext(ctx context.Context, requireSampled bool) string {
return spanCtx.TraceID().String()
}
func ServerTimingForSpan(span trace.Span) string {
spanCtx := span.SpanContext()
if !spanCtx.HasTraceID() || !spanCtx.IsValid() {
return ""
}
return fmt.Sprintf("00-%s-%s-01", spanCtx.TraceID().String(), spanCtx.SpanID().String())
}
// Error sets the status to error and record the error as an exception in the provided span.
func Error(span trace.Span, err error) error {
attr := []attribute.KeyValue{}