Sha256: 4f0762dab7875ed6f2918153b7f16c534efc0e865878cc3a6195b6d7d368fc3d
Contents?: true
Size: 598 Bytes
Versions: 9
Compression:
Stored size: 598 Bytes
Contents
module PulseMeter module Sensor module Timelined # Average value over interval class Average < Timeline def aggregate_event(key, value) redis.hincrby(key, :count, 1) redis.hincrby(key, :sum, value) end def summarize(key) count = redis.hget(key, :count) sum = redis.hget(key, :sum) if count && !count.empty? sum.to_f / count.to_f else 0 end end private def deflate(value) value.to_f end end end end end
Version data entries
9 entries across 9 versions & 1 rubygems