Class: Metrics::Instruments::PostProcessTimer
- Defined in:
- lib/ruby-metrics/instruments/post_process_timer.rb
Instance Attribute Summary
Attributes inherited from Timer
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ PostProcessTimer
constructor
A new instance of PostProcessTimer.
- #update(timestamp, duration, unit) ⇒ Object
- #update_timer(timestamp, duration) ⇒ Object
Methods inherited from Timer
#as_json, #clear, #count, #fifteen_minute_rate, #five_minute_rate, #max, #mean, #mean_rate, #min, #one_minute_rate, #quantiles, #std_dev, #time, #to_json, #values
Methods included from TimeConversion
Constructor Details
#initialize(options = {}) ⇒ PostProcessTimer
Returns a new instance of PostProcessTimer.
6 7 8 9 10 11 12 13 14 |
# File 'lib/ruby-metrics/instruments/post_process_timer.rb', line 6 def initialize( = {}) @meter = PostProcessMeter.new @histogram = ExponentialHistogram.new @duration_unit = [:duration_unit] || :seconds @rate_unit = [:rate_unit] || :seconds clear end |
Instance Method Details
#update(timestamp, duration, unit) ⇒ Object
16 17 18 19 |
# File 'lib/ruby-metrics/instruments/post_process_timer.rb', line 16 def update(, duration, unit) mult = convert_to_ns(1, unit) self.update_timer(, duration * mult) end |
#update_timer(timestamp, duration) ⇒ Object
21 22 23 24 25 26 |
# File 'lib/ruby-metrics/instruments/post_process_timer.rb', line 21 def update_timer(, duration) if duration >= 0 @histogram.update(duration) @meter.mark end end |