From 255c04bc200a2665681c9ed8e035882ff3cd2bfa Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Wed, 7 Dec 2022 09:43:57 -0800 Subject: [PATCH] lib/querytracer: put the version of VictoriaMetrics in the first message of query trace This should simplify further debugging, since the first thing to start the debugging by query trace is to know the version of VictoriaMetrics, which produced this trace. --- docs/CHANGELOG.md | 1 + lib/querytracer/tracer.go | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 3387d86d9..82d8807d7 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -57,6 +57,7 @@ The following tip changes can be tested by building VictoriaMetrics components f * FEATURE: [vmui](https://docs.victoriametrics.com/#vmui): provide fast path for hiding results for all the queries except the given one by clicking `eye` icon with `ctrl` key pressed. See [this feature request](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3446). * FEATURE: [MetricsQL](https://docs.victoriametrics.com/MetricsQL.html): add `range_trim_spikes(phi, q)` function for trimming `phi` percent of the largest spikes per each time series returned by `q`. See [these docs](https://docs.victoriametrics.com/MetricsQL.html#range_trim_spikes). * FEATURE: [vmgateway](https://docs.victoriametrics.com/vmgateway.html): add support for JWT token signature verification. See [these docs](https://docs.victoriametrics.com/vmgateway.html#jwt-signature-verification) for details. +* FEATURE: put the version of VictoriaMetrics in the first message of [query trace](https://docs.victoriametrics.com/#query-tracing). This should simplify debugging. * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly pass HTTP headers during the alert state restore procedure. See [this issue](https://github.com/VictoriaMetrics/VictoriaMetrics/issues/3418). * BUGFIX: [vmalert](https://docs.victoriametrics.com/vmalert.html): properly specify rule evaluation step during the [replay mode](https://docs.victoriametrics.com/vmalert.html#rules-backfilling). The `step` value was previously overriden by `-datasource.queryStep` command-line flag. diff --git a/lib/querytracer/tracer.go b/lib/querytracer/tracer.go index ebcf5d4fd..1b3dde722 100644 --- a/lib/querytracer/tracer.go +++ b/lib/querytracer/tracer.go @@ -8,6 +8,8 @@ import ( "io" "strings" "time" + + "github.com/VictoriaMetrics/VictoriaMetrics/lib/buildinfo" ) var denyQueryTracing = flag.Bool("denyQueryTracing", false, "Whether to disable the ability to trace queries. See https://docs.victoriametrics.com/#query-tracing") @@ -42,8 +44,10 @@ func New(enabled bool, format string, args ...interface{}) *Tracer { if *denyQueryTracing || !enabled { return nil } + message := fmt.Sprintf(format, args...) + message = buildinfo.Version + ": " + message return &Tracer{ - message: fmt.Sprintf(format, args...), + message: message, startTime: time.Now(), } }