From efdc3c71afe2c3da2f6816d6b6d3a46b80584560 Mon Sep 17 00:00:00 2001 From: Aliaksandr Valialkin Date: Tue, 1 Dec 2020 00:14:06 +0200 Subject: [PATCH] app/vmselect/searchutils: return elapsed time in Deadline.String() output This should improve debuggability for error messages containing Deadline.String() output --- app/vmselect/searchutils/searchutils.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/vmselect/searchutils/searchutils.go b/app/vmselect/searchutils/searchutils.go index 85e0a4688..c3c5c5511 100644 --- a/app/vmselect/searchutils/searchutils.go +++ b/app/vmselect/searchutils/searchutils.go @@ -184,5 +184,7 @@ func (d *Deadline) Deadline() uint64 { // String returns human-readable string representation for d. func (d *Deadline) String() string { - return fmt.Sprintf("%.3f seconds; the timeout can be adjusted with `%s` command-line flag", d.timeout.Seconds(), d.flagHint) + startTime := time.Unix(int64(d.deadline), 0).Add(-d.timeout) + elapsed := time.Since(startTime) + return fmt.Sprintf("%.3f seconds (elapsed %.3f seconds); the timeout can be adjusted with `%s` command-line flag", d.timeout.Seconds(), elapsed.Seconds(), d.flagHint) }