Sha256: 1481304ab7a323f045430c7e4945a822353bc8871bdeea438be4780f2568a6bb
Contents?: true
Size: 919 Bytes
Versions: 2
Compression:
Stored size: 919 Bytes
Contents
require 'statsd' module Fozzie module Classes class AbstractFozzie < Statsd::Client attr_reader :prefix def initialize(host, port, prefix = nil) @prefix = prefix super host, port end def time_for(data, &block) tick = Time.now.usec block.call tock = Time.now.usec timing(data, (tock - tick)) 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 end end NAMESPACES = %w{Stats S} def self.included(klass) host, port, prefix = Fozzie.c.host, Fozzie.c.port, Fozzie.c.data_prefix NAMESPACES.each do |klas| # set a constant Kernel.const_set(klas, AbstractFozzie.new(host, port, prefix)) unless const_defined?(klas) end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
fozzie-0.0.2 | lib/fozzie/classes.rb |
fozzie-0.0.1 | lib/fozzie/classes.rb |