mirror of
https://github.com/prometheus/prometheus.git
synced 2024-12-27 14:39:40 -08:00
Merge pull request #1158 from prometheus/delta
promql: Remove deprecated 2nd argument to delta()
This commit is contained in:
commit
bbdfb10da1
|
@ -44,8 +44,9 @@ func funcTime(ev *evaluator, args Expressions) model.Value {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// === delta(matrix model.ValMatrix, isCounter=0 model.ValScalar) Vector ===
|
// === delta(matrix model.ValMatrix) Vector ===
|
||||||
func funcDelta(ev *evaluator, args Expressions) model.Value {
|
func funcDelta(ev *evaluator, args Expressions) model.Value {
|
||||||
|
// This function still takes a 2nd argument for use by rate() and increase().
|
||||||
isCounter := len(args) >= 2 && ev.evalInt(args[1]) > 0
|
isCounter := len(args) >= 2 && ev.evalInt(args[1]) > 0
|
||||||
resultVector := vector{}
|
resultVector := vector{}
|
||||||
|
|
||||||
|
@ -763,11 +764,10 @@ var functions = map[string]*Function{
|
||||||
Call: funcCountScalar,
|
Call: funcCountScalar,
|
||||||
},
|
},
|
||||||
"delta": {
|
"delta": {
|
||||||
Name: "delta",
|
Name: "delta",
|
||||||
ArgTypes: []model.ValueType{model.ValMatrix, model.ValScalar},
|
ArgTypes: []model.ValueType{model.ValMatrix},
|
||||||
OptionalArgs: 1, // The 2nd argument is deprecated.
|
ReturnType: model.ValVector,
|
||||||
ReturnType: model.ValVector,
|
Call: funcDelta,
|
||||||
Call: funcDelta,
|
|
||||||
},
|
},
|
||||||
"deriv": {
|
"deriv": {
|
||||||
Name: "deriv",
|
Name: "deriv",
|
||||||
|
|
15
promql/testdata/legacy.test
vendored
15
promql/testdata/legacy.test
vendored
|
@ -133,16 +133,6 @@ eval instant at 50m rate(http_requests[25m]) * 25 * 60
|
||||||
{group="production", instance="1", job="api-server"} 100
|
{group="production", instance="1", job="api-server"} 100
|
||||||
{group="production", instance="1", job="app-server"} 300
|
{group="production", instance="1", job="app-server"} 300
|
||||||
|
|
||||||
eval instant at 50m delta(http_requests[25m], 1)
|
|
||||||
{group="canary", instance="0", job="api-server"} 150
|
|
||||||
{group="canary", instance="0", job="app-server"} 350
|
|
||||||
{group="canary", instance="1", job="api-server"} 200
|
|
||||||
{group="canary", instance="1", job="app-server"} 400
|
|
||||||
{group="production", instance="0", job="api-server"} 50
|
|
||||||
{group="production", instance="0", job="app-server"} 250
|
|
||||||
{group="production", instance="1", job="api-server"} 100
|
|
||||||
{group="production", instance="1", job="app-server"} 300
|
|
||||||
|
|
||||||
eval_ordered instant at 50m sort(http_requests)
|
eval_ordered instant at 50m sort(http_requests)
|
||||||
http_requests{group="production", instance="0", job="api-server"} 100
|
http_requests{group="production", instance="0", job="api-server"} 100
|
||||||
http_requests{group="production", instance="1", job="api-server"} 200
|
http_requests{group="production", instance="1", job="api-server"} 200
|
||||||
|
@ -209,11 +199,6 @@ eval instant at 50m delta(http_requests{group="canary", instance="1", job="app-s
|
||||||
{group="canary", instance="1", job="app-server"} 288
|
{group="canary", instance="1", job="app-server"} 288
|
||||||
|
|
||||||
|
|
||||||
# Deltas should perform the same operation when 2nd argument is 0.
|
|
||||||
eval instant at 50m delta(http_requests{group="canary", instance="1", job="app-server"}[18m], 0)
|
|
||||||
{group="canary", instance="1", job="app-server"} 288
|
|
||||||
|
|
||||||
|
|
||||||
# Rates should calculate per-second rates.
|
# Rates should calculate per-second rates.
|
||||||
eval instant at 50m rate(http_requests{group="canary", instance="1", job="app-server"}[60m])
|
eval instant at 50m rate(http_requests{group="canary", instance="1", job="app-server"}[60m])
|
||||||
{group="canary", instance="1", job="app-server"} 0.26666666666666666
|
{group="canary", instance="1", job="app-server"} 0.26666666666666666
|
||||||
|
|
Loading…
Reference in a new issue