Merge pull request #9072 from darshanime/add_stringer_to_query

Add Stringer to Query interface
This commit is contained in:
Julien Pivotto 2021-07-13 16:21:42 +02:00 committed by GitHub
commit a789ea6447
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 9 additions and 0 deletions

View File

@ -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