Class: SimpleMetrics::DataPoint::Gauge
- Defined in:
- lib/simple_metrics/data_point/gauge.rb
Instance Attribute Summary
Attributes inherited from Base
#id, #name, #sum, #total, #ts, #type, #value
Instance Method Summary collapse
- #combine(dp) ⇒ Object
-
#initialize(attributes) ⇒ Gauge
constructor
A new instance of Gauge.
Methods inherited from Base
#attributes, #counter?, #event?, #gauge?, #timestamp, #timing?, #to_s
Constructor Details
#initialize(attributes) ⇒ Gauge
Returns a new instance of Gauge.
5 6 7 8 9 |
# File 'lib/simple_metrics/data_point/gauge.rb', line 5 def initialize(attributes) super(attributes) @type = 'g' @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/gauge.rb', line 11 def combine(dp) @total += 1 @sum += dp.value @value = @sum / @total self end |