Skip to content

Commit

Permalink
promql: Remove deprecated 2nd argument to delta()
Browse files Browse the repository at this point in the history
This change is breaking, use increase() instead.

I'm not cleaning up the function in this PR, as my solution to #581 will
rewrite and simplify increase/rate/delta.
  • Loading branch information
brian-brazil authored and fabxc committed Jan 11, 2016
1 parent 180b105 commit b48d2b1
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
12 changes: 6 additions & 6 deletions promql/functions.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
// This function still takes a 2nd argument for use by rate() and increase().
isCounter := len(args) >= 2 && ev.evalInt(args[1]) > 0
resultVector := vector{}

Expand Down Expand Up @@ -763,11 +764,10 @@ var functions = map[string]*Function{
Call: funcCountScalar,
},
"delta": {
Name: "delta",
ArgTypes: []model.ValueType{model.ValMatrix, model.ValScalar},
OptionalArgs: 1, // The 2nd argument is deprecated.
ReturnType: model.ValVector,
Call: funcDelta,
Name: "delta",
ArgTypes: []model.ValueType{model.ValMatrix},
ReturnType: model.ValVector,
Call: funcDelta,
},
"deriv": {
Name: "deriv",
Expand Down
15 changes: 0 additions & 15 deletions promql/testdata/legacy.test
Original file line number Diff line number Diff line change
Expand Up @@ -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="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)
http_requests{group="production", instance="0", job="api-server"} 100
http_requests{group="production", instance="1", job="api-server"} 200
Expand Down Expand Up @@ -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


# 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.
eval instant at 50m rate(http_requests{group="canary", instance="1", job="app-server"}[60m])
{group="canary", instance="1", job="app-server"} 0.26666666666666666
Expand Down

0 comments on commit b48d2b1

Please sign in to comment.