lib/fozzie/classes.rb in fozzie-0.0.2 vs lib/fozzie/classes.rb in fozzie-0.0.3
- old
+ new
@@ -1,34 +1,50 @@
require 'statsd'
module Fozzie
module Classes
- class AbstractFozzie < Statsd::Client
+ class AbstractFozzie < Statsd
attr_reader :prefix
def initialize(host, port, prefix = nil)
- @prefix = prefix
+ @namespace = prefix unless prefix.nil?
super host, port
end
- def time_for(data, &block)
- tick = Time.now.usec
- block.call
- tock = Time.now.usec
- timing(data, (tock - tick))
+ def time_to_do(stat, sample_rate=1, &block); time_for(stat, sample_rate, &block); end
+ def time_for(stat, sample_rate=1, &block)
+ begin
+ time(stat, sample_rate, &block)
+ rescue => exc
+ yield block
+ end
end
+ def committed; commit; end
+ def commit
+ event :commit
+ end
+
+ def build; built; end
+ def built
+ event :build
+ end
+
+ def deploy; deployed; end
+ def deployed
+ event :deploy
+ end
+
private
- # Overload the send_stats method to automicatially prefix the data bucket string
- def send_stats(data, sample_rate = 1)
- super "#{@prefix}#{data}", sample_rate
+ def event(type)
+ timing "event.#{type.to_s}", Time.now.usec
end
end
- NAMESPACES = %w{Stats S}
+ NAMESPACES = %w{Stats S Statistics Warehouse}
def self.included(klass)
host, port, prefix = Fozzie.c.host, Fozzie.c.port, Fozzie.c.data_prefix
NAMESPACES.each do |klas|
# set a constant
\ No newline at end of file