Class: SimpleMetrics::DataPoint::Counter
- Defined in:
- lib/simple_metrics/data_point/counter.rb
Instance Attribute Summary
Attributes inherited from Base
#id, #name, #sum, #total, #ts, #type, #value
Instance Method Summary collapse
- #combine(dp) ⇒ Object
-
#initialize(attributes) ⇒ Counter
constructor
A new instance of Counter.
Methods inherited from Base
#attributes, #counter?, #event?, #gauge?, #timestamp, #timing?, #to_s
Constructor Details
#initialize(attributes) ⇒ Counter
Returns a new instance of Counter.
5 6 7 8 9 |
# File 'lib/simple_metrics/data_point/counter.rb', line 5 def initialize(attributes) super(attributes) @type = 'c' @value = (@value.to_i || 1) * (1.0 / (@sample_rate || 1).to_f) end |
Instance Method Details
#combine(dp) ⇒ Object
11 12 13 14 15 16 |
# File 'lib/simple_metrics/data_point/counter.rb', line 11 def combine(dp) @total += 1 @value += dp.value @sum += dp.value self end |