Sha256: bea6bc3a5cbbb0592fc0306bc86620e104168d52f04a8a8648e5e32e00235ae6

Contents?: true

Size: 484 Bytes

Versions: 3

Compression:

Stored size: 484 Bytes

Contents

class Circuitbox
  class Timer
    class Monotonic
      def initialize(time_unit = :millisecond)
        @time_unit = time_unit
      end

      def time(service, notifier, metric_name)
        before = Process.clock_gettime(Process::CLOCK_MONOTONIC, @time_unit)
        result = yield
        total_time = Process.clock_gettime(Process::CLOCK_MONOTONIC, @time_unit) - before
        notifier.metric_gauge(service, metric_name, total_time)
        result
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
circuitbox-2.0.0.pre3 lib/circuitbox/timer/monotonic.rb
circuitbox-2.0.0.pre2 lib/circuitbox/timer/monotonic.rb
circuitbox-2.0.0.pre1 lib/circuitbox/timer/monotonic.rb