Browse Source

Fix time() behavior.

time() should return the timestamp for which the query is executed, not
the actual current time.

Change-Id: I430a45cabad7785cd58f95b1028a71dff4c87710
changes/50/350/2
Julius Volz 10 years ago
parent
commit
54eb21b22a
  1. 2
      rules/ast/functions.go
  2. 6
      rules/rules_test.go

2
rules/ast/functions.go

@ -75,7 +75,7 @@ func (function *Function) CheckArgTypes(args []Node) error {
// === time() clientmodel.SampleValue ===
func timeImpl(timestamp clientmodel.Timestamp, view *viewAdapter, args []Node) interface{} {
return clientmodel.SampleValue(time.Now().Unix())
return clientmodel.SampleValue(timestamp.Unix())
}
// === delta(matrix MatrixNode, isCounter ScalarNode) Vector ===

6
rules/rules_test.go

@ -496,6 +496,12 @@ func TestExpressions(t *testing.T) {
fullRanges: 2,
intervalRanges: 0,
},
{
expr: `time()`,
output: []string{`scalar: 3000 @[%v]`},
fullRanges: 0,
intervalRanges: 0,
},
}
tieredStorage, closer := newTestStorage(t)

Loading…
Cancel
Save