Skip to content

Commit

Permalink
gauge.ticks_in should include the current tick
Browse files Browse the repository at this point in the history
  • Loading branch information
asmuth committed Jun 4, 2012
1 parent 8d36f7e commit 7a718f5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/fnordmetric/gauge_calculations.rb
Expand Up @@ -12,8 +12,8 @@ module FnordMetric::GaugeCalculations
(_v.to_f / (sync_redis.get(tick_key(_t, :"value-count"))||1).to_i)
}

def ticks_in(r, _tick=tick)
(((r.last-r.first)/_tick.to_f).ceil+1).times.map{ |n| tick_at(r.first + _tick*(n-1), _tick) }
def ticks_in(r, _tick=tick, overflow=0)
(((r.last-r.first)/_tick.to_f).ceil+1+overflow).times.map{ |n| tick_at(r.first + _tick*(n-1), _tick) }
end

def values_in(range)
Expand Down
2 changes: 1 addition & 1 deletion lib/fnordmetric/gauges/distribution_gauge.rb
Expand Up @@ -14,7 +14,7 @@ def render(namespace, event)
h[k] = { :min => nil, :max => 0, :avg => [] }
end

ticks_in(@interval).each do |_tick|
ticks_in(@interval, tick, 1).each do |_tick|
tkey = tick_key(_tick, :histogram)

sync_redis.hgetall(tkey).each do |_val, _count|
Expand Down
2 changes: 1 addition & 1 deletion lib/fnordmetric/gauges/toplist_gauge.rb
Expand Up @@ -4,7 +4,7 @@ def render(namespace, event)
@interval = parse_interval(event["interval"])

@toplist = FnordMetric::Toplist.new
@all_ticks = ticks_in(@interval)
@all_ticks = ticks_in(@interval, tick, 1)

@all_ticks.each do |_tick|
field_values_at(_tick, :limit => top_k, :append => :toplist).each do |item, count|
Expand Down

0 comments on commit 7a718f5

Please sign in to comment.