Class: Prometheus::Client::Histogram::Value
- Inherits:
-
Hash
- Object
- Hash
- Prometheus::Client::Histogram::Value
- Defined in:
- lib/prometheus/client/histogram.rb
Overview
Value represents the state of a Histogram at a given point.
Instance Attribute Summary collapse
-
#sum ⇒ Object
Returns the value of attribute sum.
-
#total ⇒ Object
Returns the value of attribute total.
Instance Method Summary collapse
-
#initialize(buckets) ⇒ Value
constructor
A new instance of Value.
- #observe(value) ⇒ Object
Constructor Details
#initialize(buckets) ⇒ Value
Returns a new instance of Value.
15 16 17 18 19 20 21 22 |
# File 'lib/prometheus/client/histogram.rb', line 15 def initialize(buckets) @sum = 0.0 @total = 0.0 buckets.each do |bucket| self[bucket] = 0.0 end end |
Instance Attribute Details
#sum ⇒ Object
Returns the value of attribute sum.
13 14 15 |
# File 'lib/prometheus/client/histogram.rb', line 13 def sum @sum end |
#total ⇒ Object
Returns the value of attribute total.
13 14 15 |
# File 'lib/prometheus/client/histogram.rb', line 13 def total @total end |
Instance Method Details
#observe(value) ⇒ Object
24 25 26 27 28 29 30 31 |
# File 'lib/prometheus/client/histogram.rb', line 24 def observe(value) @sum += value @total += 1 each_key do |bucket| self[bucket] += 1 if value <= bucket end end |