Class: Prometheus::Client::Histogram
- Defined in:
- lib/prometheus/client/histogram.rb
Overview
A histogram samples observations (usually things like request durations or response sizes) and counts them in configurable buckets. It also provides a sum of all observed values.
Defined Under Namespace
Classes: Value
Constant Summary collapse
- DEFAULT_BUCKETS =
DEFAULT_BUCKETS are the default Histogram buckets. The default buckets are tailored to broadly measure the response time (in seconds) of a network service. (From DefBuckets client_golang)
[0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10].freeze
Instance Attribute Summary
Attributes inherited from Metric
#base_labels, #docstring, #name
Instance Method Summary collapse
-
#initialize(name, docstring, base_labels = {}, buckets = DEFAULT_BUCKETS) ⇒ Histogram
constructor
Offer a way to manually specify buckets.
- #observe(labels, value) ⇒ Object
- #type ⇒ Object
Methods inherited from Metric
Constructor Details
#initialize(name, docstring, base_labels = {}, buckets = DEFAULT_BUCKETS) ⇒ Histogram
Offer a way to manually specify buckets
41 42 43 44 45 46 47 |
# File 'lib/prometheus/client/histogram.rb', line 41 def initialize(name, docstring, base_labels = {}, buckets = DEFAULT_BUCKETS) raise ArgumentError, 'Unsorted buckets, typo?' unless sorted? buckets @buckets = buckets super(name, docstring, base_labels) end |
Instance Method Details
#observe(labels, value) ⇒ Object
53 54 55 56 57 58 59 60 |
# File 'lib/prometheus/client/histogram.rb', line 53 def observe(labels, value) if labels[:le] raise ArgumentError, 'Label with name "le" is not permitted' end label_set = label_set_for(labels) synchronize { @values[label_set].observe(value) } end |
#type ⇒ Object
49 50 51 |
# File 'lib/prometheus/client/histogram.rb', line 49 def type :histogram end |