From 364c40be577b258401a02e23578815ee81492356 Mon Sep 17 00:00:00 2001 From: darshanime Date: Sun, 11 Jul 2021 19:23:34 +0530 Subject: [PATCH] Add Stringer to Query interface Signed-off-by: darshanime --- promql/engine.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/promql/engine.go b/promql/engine.go index 46715fbb3..e438fe87f 100644 --- a/promql/engine.go +++ b/promql/engine.go @@ -117,6 +117,8 @@ type Query interface { Stats() *stats.QueryTimers // Cancel signals that a running query execution should be aborted. Cancel() + // String returns the original query string. + String() string } // query implements the Query interface. @@ -141,10 +143,17 @@ type query struct { type QueryOrigin struct{} // Statement implements the Query interface. +// Calling this after Exec may result in panic, +// see https://github.com/prometheus/prometheus/issues/8949. func (q *query) Statement() parser.Statement { return q.stmt } +// String implements the Query interface. +func (q *query) String() string { + return q.q +} + // Stats implements the Query interface. func (q *query) Stats() *stats.QueryTimers { return q.stats