Sha256: 831075641bb3df26cfadb2b00a7324aa1f772048ae4cce27c096049a9ac78814
Contents?: true
Size: 842 Bytes
Versions: 24
Compression:
Stored size: 842 Bytes
Contents
require 'securerandom' module Harness class Counter < Measurement def self.from_event(event) if event.payload[:counter].is_a? Hash counter = new event.payload[:counter] elsif event.payload[:counter].is_a?(Symbol) || event.payload[:counter].is_a?(String) counter = new :id => event.payload[:counter].to_s else counter = new end counter.id ||= event.name Harness.redis.sadd 'counters', counter.id if event.payload[:counter].is_a? Fixnum counter.value = event.payload[:counter] end if counter.value Harness.redis.set counter.id, counter.value else counter.value = Harness.redis.incr(counter.id).to_i end Harness.redis.zadd "meters/#{counter.id}", counter.time.to_f, counter.value counter end end end
Version data entries
24 entries across 24 versions & 1 rubygems