mirror of https://github.com/prometheus/prometheus
add negative offset to printer
Signed-off-by: schou <pschou@users.noreply.github.com>pull/8487/head
parent
f80b52be69
commit
3bafe17870
|
@ -116,8 +116,10 @@ func (node *MatrixSelector) String() string {
|
||||||
// Copy the Vector selector before changing the offset
|
// Copy the Vector selector before changing the offset
|
||||||
vecSelector := *node.VectorSelector.(*VectorSelector)
|
vecSelector := *node.VectorSelector.(*VectorSelector)
|
||||||
offset := ""
|
offset := ""
|
||||||
if vecSelector.OriginalOffset != time.Duration(0) {
|
if vecSelector.OriginalOffset > time.Duration(0) {
|
||||||
offset = fmt.Sprintf(" offset %s", model.Duration(vecSelector.OriginalOffset))
|
offset = fmt.Sprintf(" offset %s", model.Duration(vecSelector.OriginalOffset))
|
||||||
|
} else if vecSelector.OriginalOffset < time.Duration(0) {
|
||||||
|
offset = fmt.Sprintf(" offset -%s", model.Duration(-vecSelector.OriginalOffset))
|
||||||
}
|
}
|
||||||
at := ""
|
at := ""
|
||||||
if vecSelector.Timestamp != nil {
|
if vecSelector.Timestamp != nil {
|
||||||
|
@ -147,8 +149,10 @@ func (node *SubqueryExpr) String() string {
|
||||||
step = model.Duration(node.Step).String()
|
step = model.Duration(node.Step).String()
|
||||||
}
|
}
|
||||||
offset := ""
|
offset := ""
|
||||||
if node.OriginalOffset != time.Duration(0) {
|
if node.OriginalOffset > time.Duration(0) {
|
||||||
offset = fmt.Sprintf(" offset %s", model.Duration(node.OriginalOffset))
|
offset = fmt.Sprintf(" offset %s", model.Duration(node.OriginalOffset))
|
||||||
|
} else if node.OriginalOffset < time.Duration(0) {
|
||||||
|
offset = fmt.Sprintf(" offset -%s", model.Duration(-node.OriginalOffset))
|
||||||
}
|
}
|
||||||
at := ""
|
at := ""
|
||||||
if node.Timestamp != nil {
|
if node.Timestamp != nil {
|
||||||
|
@ -187,8 +191,10 @@ func (node *VectorSelector) String() string {
|
||||||
labelStrings = append(labelStrings, matcher.String())
|
labelStrings = append(labelStrings, matcher.String())
|
||||||
}
|
}
|
||||||
offset := ""
|
offset := ""
|
||||||
if node.OriginalOffset != time.Duration(0) {
|
if node.OriginalOffset > time.Duration(0) {
|
||||||
offset = fmt.Sprintf(" offset %s", model.Duration(node.OriginalOffset))
|
offset = fmt.Sprintf(" offset %s", model.Duration(node.OriginalOffset))
|
||||||
|
} else if node.OriginalOffset < time.Duration(0) {
|
||||||
|
offset = fmt.Sprintf(" offset -%s", model.Duration(-node.OriginalOffset))
|
||||||
}
|
}
|
||||||
at := ""
|
at := ""
|
||||||
if node.Timestamp != nil {
|
if node.Timestamp != nil {
|
||||||
|
|
|
@ -77,12 +77,18 @@ func TestExprString(t *testing.T) {
|
||||||
{
|
{
|
||||||
in: `a offset 1m`,
|
in: `a offset 1m`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: `a offset -7m`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
in: `a{c="d"}[5m] offset 1m`,
|
in: `a{c="d"}[5m] offset 1m`,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
in: `a[5m] offset 1m`,
|
in: `a[5m] offset 1m`,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
in: `a[12m] offset -3m`,
|
||||||
|
},
|
||||||
{
|
{
|
||||||
in: `a[1h:5m] offset 1m`,
|
in: `a[1h:5m] offset 1m`,
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in New Issue