Permalink
Browse files

Histograms can be the delta between two events

Useful pattern for graphing error rates if you know (attempt, success)

Change-Id: Ib09853d40e31bee34990678af3a34faa9695b808
Reviewed-on: https://gerrit.causes.com/2344
Tested-by: Adam Derewecki <adam@causes.com>
Reviewed-by: Adam Derewecki <adam@causes.com>
  • Loading branch information...
Adam Derewecki
Adam Derewecki committed Jan 11, 2012
1 parent 3a3b4f3 commit ab13d1b86069129f730ffb73c82252472fa2570b
Showing with 17 additions and 0 deletions.
  1. +17 −0 lib/duckweed/app.rb
View
@@ -71,6 +71,16 @@ class App < Sinatra::Base
histogram(params[:event], params[:granularity].to_sym, params[:quantity].to_i)
end
+ get '/histogram-delta/:event_a/:event_b' do
+ histogram_delta(params[:event_a], params[:event_b], :minutes, 60)
+ end
+
+ get '/histogram-delta/:event_a/:event_b/:granularity/:quantity' do
+ check_request_limits!
+ histogram_delta(params[:event_a], params[:event_b],
+ params[:granularity].to_sym, params[:quantity].to_i)
+ end
+
get '/accumulate/:event' do
accumulate(params[:event], :minutes, 60)
end
@@ -299,6 +309,13 @@ def histogram(event, granularity, quantity)
geckoboard_jsonify_for_chart(values, times)
end
+ def histogram_delta(event_a, event_b, granularity, quantity)
+ values_a, times_a = values_and_times_for(granularity, event_a, quantity)
+ values_b, times_b = values_and_times_for(granularity, event_b, quantity)
+ values = values_a.zip(values_b).map {|a, b| a - b}
+ geckoboard_jsonify_for_chart(values, times_a)
+ end
+
def accumulate(event, granularity, quantity)
# Fetch all the unexpired data we have, so that we can start counting from "1"
values, times = values_and_times_for(granularity, event, max_buckets(granularity))

0 comments on commit ab13d1b

Please sign in to comment.