diff --git a/docs/configuration/configuration.md b/docs/configuration/configuration.md index 060319ae92..1525269441 100644 --- a/docs/configuration/configuration.md +++ b/docs/configuration/configuration.md @@ -3746,3 +3746,6 @@ headers: tls_config: [ ] ``` + +If query logging and tracing are both enabled, a traceID and spanID will be injected +into the query log file for use in log/trace correlation. diff --git a/promql/engine.go b/promql/engine.go index 970edcf78f..524ad807d1 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -700,7 +700,11 @@ func (ng *Engine) exec(ctx context.Context, q *query) (v parser.Value, ws annota } f = append(f, slog.Any("stats", stats.NewQueryStats(q.Stats()))) if span := trace.SpanFromContext(ctx); span != nil { - f = append(f, slog.Any("spanID", span.SpanContext().SpanID())) + spanCtx := span.SpanContext() + f = append(f, + slog.Any("spanID", spanCtx.SpanID()), + slog.Any("traceID", spanCtx.TraceID()), + ) } if origin := ctx.Value(QueryOrigin{}); origin != nil { for k, v := range origin.(map[string]any) {