Class: Metrics::Instruments::PostProcessMeter

Inherits:
Meter
  • Object
show all
Defined in:
lib/ruby-metrics/instruments/post_process_meter.rb

Constant Summary

Constants inherited from Meter

Meter::FIFTEEN_MINUTE_FACTOR, Meter::FIVE_MINUTE_FACTOR, Meter::INTERVAL, Meter::INTERVAL_IN_NS, Meter::ONE_MINUTE_FACTOR

Instance Attribute Summary

Attributes inherited from Meter

#count

Instance Method Summary collapse

Methods inherited from Meter

#as_json, #calc_rate, #clear, #fifteen_minute_rate, #five_minute_rate, #mean_rate, #one_minute_rate, #tick, #to_json

Methods included from TimeConversion

#convert_to_ns

Constructor Details

#initializePostProcessMeter

Returns a new instance of PostProcessMeter.



6
7
8
# File 'lib/ruby-metrics/instruments/post_process_meter.rb', line 6

def initialize
  super(:no_thread => true)
end

Instance Method Details

#interval_difference(timestamp) ⇒ Object



19
20
21
22
23
24
25
26
# File 'lib/ruby-metrics/instruments/post_process_meter.rb', line 19

def interval_difference(timestamp)
  if @interval_start
    ((timestamp - @interval_start) % INTERVAL).to_i
  else
    @interval_start = timestamp
    0
  end
end

#mark(timestamp, count = 1) ⇒ Object



10
11
12
13
14
15
16
17
# File 'lib/ruby-metrics/instruments/post_process_meter.rb', line 10

def mark(timestamp, count = 1)
  ticks = interval_difference(timestamp)
  if ticks > 0
    ticks.times { self.tick }
    @interval_start = @interval_start + INTERVAL * ticks
  end
  @count += count
end