mirror of https://github.com/prometheus/prometheus
fix subquery with offset conversion to string (#6373)
Signed-off-by: Bartosz Jakubski <b.jakubski@gmail.com>pull/6380/head^2
parent
c2cb1e4103
commit
80ba03c67d
|
@ -128,7 +128,11 @@ func (node *SubqueryExpr) String() string {
|
|||
if node.Step != 0 {
|
||||
step = model.Duration(node.Step).String()
|
||||
}
|
||||
return fmt.Sprintf("%s[%s:%s]", node.Expr.String(), model.Duration(node.Range), step)
|
||||
offset := ""
|
||||
if node.Offset != time.Duration(0) {
|
||||
offset = fmt.Sprintf(" offset %s", model.Duration(node.Offset))
|
||||
}
|
||||
return fmt.Sprintf("%s[%s:%s]%s", node.Expr.String(), model.Duration(node.Range), step, offset)
|
||||
}
|
||||
|
||||
func (node *NumberLiteral) String() string {
|
||||
|
|
|
@ -83,6 +83,9 @@ func TestExprString(t *testing.T) {
|
|||
{
|
||||
in: `a[5m] offset 1m`,
|
||||
},
|
||||
{
|
||||
in: `a[1h:5m] offset 1m`,
|
||||
},
|
||||
{
|
||||
in: `{__name__="a"}`,
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue