Merge pull request #1158 from prometheus/delta

promql: Remove deprecated 2nd argument to delta()
This commit is contained in:
Brian Brazil 2015-10-10 21:24:16 +01:00
commit bbdfb10da1
2 changed files with 6 additions and 21 deletions

View file

@ -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",

View file

@ -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