mirror of
https://github.com/prometheus/prometheus.git
synced 2024-11-10 23:54:05 -08:00
Fix time() behavior.
time() should return the timestamp for which the query is executed, not the actual current time. Change-Id: I430a45cabad7785cd58f95b1028a71dff4c87710
This commit is contained in:
parent
527831ec6e
commit
54eb21b22a
|
@ -75,7 +75,7 @@ func (function *Function) CheckArgTypes(args []Node) error {
|
||||||
|
|
||||||
// === time() clientmodel.SampleValue ===
|
// === time() clientmodel.SampleValue ===
|
||||||
func timeImpl(timestamp clientmodel.Timestamp, view *viewAdapter, args []Node) interface{} {
|
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 ===
|
// === delta(matrix MatrixNode, isCounter ScalarNode) Vector ===
|
||||||
|
|
|
@ -496,6 +496,12 @@ func TestExpressions(t *testing.T) {
|
||||||
fullRanges: 2,
|
fullRanges: 2,
|
||||||
intervalRanges: 0,
|
intervalRanges: 0,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
expr: `time()`,
|
||||||
|
output: []string{`scalar: 3000 @[%v]`},
|
||||||
|
fullRanges: 0,
|
||||||
|
intervalRanges: 0,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
tieredStorage, closer := newTestStorage(t)
|
tieredStorage, closer := newTestStorage(t)
|
||||||
|
|
Loading…
Reference in a new issue