|
Prometheus Client Library for Modern C++
|
A histogram metric to represent aggregatable distributions of events. More...
#include <histogram.h>
Public Types | |
| using | BucketBoundaries = std::vector< double > |
Public Member Functions | |
| Histogram (const BucketBoundaries &buckets) | |
| Create a histogram with manually chosen buckets. | |
| void | Observe (double value) |
| Observe the given amount. | |
| void | ObserveMultiple (const std::vector< double > &bucket_increments, const double sum_of_values) |
| Observe multiple data points. | |
| ClientMetric | Collect () const |
| Get the current value of the counter. | |
Static Public Attributes | |
| static const MetricType | metric_type {MetricType::Histogram} |
A histogram metric to represent aggregatable distributions of events.
This class represents the metric type histogram: https://prometheus.io/docs/concepts/metric_types/#histogram
A histogram tracks the number of observations and the sum of the observed values, allowing to calculate the average of the observed values.
At its core a histogram has a counter per bucket. The sum of observations also behaves like a counter as long as there are no negative observations.
See https://prometheus.io/docs/practices/histograms/ for detailed explanations of histogram usage and differences to summaries.
The class is thread-safe. No concurrent call to any API of this type causes a data race.
| prometheus::Histogram::Histogram | ( | const BucketBoundaries & | buckets | ) |
Create a histogram with manually chosen buckets.
The BucketBoundaries are a list of monotonically increasing values representing the bucket boundaries. Each consecutive pair of values is interpreted as a half-open interval [b_n, b_n+1) which defines one bucket.
There is no limitation on how the buckets are divided, i.e, equal size, exponential etc..
The bucket boundaries cannot be changed once the histogram is created.
| ClientMetric prometheus::Histogram::Collect | ( | ) | const |
Get the current value of the counter.
Collect is called by the Registry when collecting metrics.
| void prometheus::Histogram::Observe | ( | double | value | ) |
Observe the given amount.
The given amount selects the 'observed' bucket. The observed bucket is chosen for which the given amount falls into the half-open interval [b_n, b_n+1). The counter of the observed bucket is incremented. Also the total sum of all observations is incremented.
| void prometheus::Histogram::ObserveMultiple | ( | const std::vector< double > & | bucket_increments, |
| const double | sum_of_values | ||
| ) |
Observe multiple data points.
Increments counters given a count for each bucket. (i.e. the caller of this function must have already sorted the values into buckets). Also increments the total sum of all observations by the given value.