#include <userver/utils/statistics/histogram.hpp>
A histogram with a dynamically-allocated array of buckets.
The trade-offs of histograms with Percentile
are:
Percentile
metrics are fundamentally non-summable across multiple hosts. Histogram
, on the other hand, are summableHistogram
takes up more storage space on the statistics server, as there are typically 20-50 buckets in a Histogram
, but only a few required percentiles in a Percentile
Percentile
metrics have almost infinite precision, limited only by the number of allocated atomic counters. The precision of Histogram
metrics is limited by the initially set boundsUsage example:
Contents of a Histogram are read using utils::statistics::HistogramView. This can be useful for writing custom metric serialization formats or for testing.
Histogram metrics can be summed using utils::statistics::HistogramAggregator.
Histogram can be used in utils::statistics::MetricTag:
Definition at line 63 of file histogram.hpp.
Public Member Functions | |
Histogram (utils::span< const double > upper_bounds) | |
Histogram (HistogramView other) | |
Copies an existing histogram. | |
Histogram (Histogram &&) noexcept | |
Histogram (const Histogram &) | |
Histogram & | operator= (Histogram &&) noexcept |
Histogram & | operator= (const Histogram &) |
void | Account (double value, std::uint64_t count=1) noexcept |
Atomically increment the bucket corresponding to the given value. | |
HistogramView | GetView () const &noexcept |
Allows reading the histogram. | |
|
explicit |
Sets upper bounds for each non-"infinite" bucket. The lowest bound is always 0.