Class: Prometheus::Client::Summary
- Extended by:
- Gem::Deprecate
- Defined in:
- lib/prometheus/client/summary.rb
Overview
Summary is an accumulator for samples. It captures Numeric data and provides an efficient quantile calculation mechanism.
Defined Under Namespace
Classes: Value
Instance Attribute Summary
Attributes inherited from Metric
#base_labels, #docstring, #name
Instance Method Summary collapse
-
#get(labels = {}) ⇒ Object
Returns the value for the given label set.
-
#initialize(name, docstring, base_labels = {}) ⇒ Summary
constructor
A new instance of Summary.
-
#observe(labels, value) ⇒ Object
(also: #add)
Records a given value.
- #type ⇒ Object
-
#values ⇒ Object
Returns all label sets with their values.
Methods included from UsesValueType
Constructor Details
#initialize(name, docstring, base_labels = {}) ⇒ Summary
Returns a new instance of Summary.
27 28 29 |
# File 'lib/prometheus/client/summary.rb', line 27 def initialize(name, docstring, base_labels = {}) super(name, docstring, base_labels) end |
Instance Method Details
#get(labels = {}) ⇒ Object
Returns the value for the given label set
45 46 47 48 49 50 51 |
# File 'lib/prometheus/client/summary.rb', line 45 def get(labels = {}) @validator.valid?(labels) synchronize do @values[labels].sum.get end end |
#observe(labels, value) ⇒ Object Also known as: add
Records a given value.
36 37 38 39 |
# File 'lib/prometheus/client/summary.rb', line 36 def observe(labels, value) label_set = label_set_for(labels) synchronize { @values[label_set].observe(value) } end |
#type ⇒ Object
31 32 33 |
# File 'lib/prometheus/client/summary.rb', line 31 def type :summary end |
#values ⇒ Object
Returns all label sets with their values
54 55 56 57 58 59 60 |
# File 'lib/prometheus/client/summary.rb', line 54 def values synchronize do @values.each_with_object({}) do |(labels, value), memo| memo[labels] = value.sum end end end |