mirror of https://github.com/prometheus/prometheus
Fix time() behavior.
time() should return the timestamp for which the query is executed, not the actual current time. Change-Id: I430a45cabad7785cd58f95b1028a71dff4c87710pull/413/head
parent
c5984f1818
commit
00b9489f1c
|
@ -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 ===
|
||||
|
|
|
@ -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…
Reference in New Issue