Sha256: 3ff4230601173f5f837e51f115efac5e6cfce936c0200456126140db7f6e559b

Contents?: true

Size: 489 Bytes

Versions: 1

Compression:

Stored size: 489 Bytes

Contents

module Napa
  module StatsDTimer
    def report_time(timer_name)
      start_time = Time.now
      yield
      response_time = (Time.now - start_time) * 1000 # statsd reports timers in milliseconds
      Napa::Stats.emitter.timing(timer_name, response_time)
    end

    module ClassMethods
      def report_time(timer_name)
        new.report_time(timer_name) do
          yield
        end
      end
    end

    def self.included(base)
      base.extend(ClassMethods)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
napa-0.4.0 lib/napa/stats_d_timer.rb