mirror of
https://github.com/prometheus/prometheus.git
synced 2026-03-04 05:01:04 +01:00
Add traceID to query logs
The query log embeds a spanID, but omits the traceID, making log/trace correlation significantly more difficult. Add the trace ID as well. This might be better done with the otelslog wrapper in https://github.com/go-slog/otelslog but this change is more minimal. This does not add trace and span IDs to other logging emitted to Prometheus's standard logger during the processing of activities in which traces may be active. Fixes #18188 Signed-off-by: Craig Ringer <craig.ringer@enterprisedb.com>
This commit is contained in:
parent
5d3f9ee39b
commit
d4b00499e8
@ -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