mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-09 23:24:05 -08:00
add negative offset to printer
Signed-off-by: schou <pschou@users.noreply.github.com>
This commit is contained in:
parent
f80b52be69
commit
3bafe17870
|
@ -116,8 +116,10 @@ func (node *MatrixSelector) String() string {
|
|||
// Copy the Vector selector before changing the offset
|
||||
vecSelector := *node.VectorSelector.(*VectorSelector)
|
||||
offset := ""
|
||||
if vecSelector.OriginalOffset != time.Duration(0) {
|
||||
if vecSelector.OriginalOffset > time.Duration(0) {
|
||||
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 := ""
|
||||
if vecSelector.Timestamp != nil {
|
||||
|
@ -147,8 +149,10 @@ func (node *SubqueryExpr) String() string {
|
|||
step = model.Duration(node.Step).String()
|
||||
}
|
||||
offset := ""
|
||||
if node.OriginalOffset != time.Duration(0) {
|
||||
if node.OriginalOffset > time.Duration(0) {
|
||||
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 := ""
|
||||
if node.Timestamp != nil {
|
||||
|
@ -187,8 +191,10 @@ func (node *VectorSelector) String() string {
|
|||
labelStrings = append(labelStrings, matcher.String())
|
||||
}
|
||||
offset := ""
|
||||
if node.OriginalOffset != time.Duration(0) {
|
||||
if node.OriginalOffset > time.Duration(0) {
|
||||
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 := ""
|
||||
if node.Timestamp != nil {
|
||||
|
|
|
@ -77,12 +77,18 @@ func TestExprString(t *testing.T) {
|
|||
{
|
||||
in: `a offset 1m`,
|
||||
},
|
||||
{
|
||||
in: `a offset -7m`,
|
||||
},
|
||||
{
|
||||
in: `a{c="d"}[5m] offset 1m`,
|
||||
},
|
||||
{
|
||||
in: `a[5m] offset 1m`,
|
||||
},
|
||||
{
|
||||
in: `a[12m] offset -3m`,
|
||||
},
|
||||
{
|
||||
in: `a[1h:5m] offset 1m`,
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue