mirror of
https://github.com/prometheus/prometheus.git
synced 2026-05-05 12:26:14 +02:00
Merge pull request #18189 from ringerc/log-trace-id
Add traceID to query logs
This commit is contained in:
commit
02b1abab5e
@ -3746,3 +3746,6 @@ headers:
|
||||
tls_config:
|
||||
[ <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.
|
||||
|
||||
@ -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) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user