userver: utils::statistics::HistogramAggregator Class Reference
Loading...
Searching...
No Matches
utils::statistics::HistogramAggregator Class Referencefinal

#include <userver/utils/statistics/histogram_aggregator.hpp>

Detailed Description

Used to aggregate multiple utils::statistics::Histogram metrics.

Usage example:

utils::statistics::Histogram histogram1{Bounds()};
AccountSome(histogram1);
AccountSome(histogram1);
utils::statistics::Histogram histogram2{Bounds()};
AccountSome(histogram2);
aggregator.Add(histogram1.GetView());
aggregator.Add(histogram2.GetView());
EXPECT_EQ(fmt::to_string(aggregator.GetView()),
"[1.5]=3,[5]=3,[42]=15,[60]=0,[inf]=3");

Definition at line 20 of file histogram_aggregator.hpp.

Public Member Functions

 HistogramAggregator (utils::span< const double > upper_bounds)
 
 HistogramAggregator (HistogramAggregator &&) noexcept
 
HistogramAggregatoroperator= (HistogramAggregator &&) noexcept
 
void Add (HistogramView other)
 Add the other histogram to the current one.
 
void AccountAt (std::size_t bucket_index, std::uint64_t count=1) noexcept
 Non-atomically increment the bucket corresponding to the given index.
 
void AccountInf (std::uint64_t count=1) noexcept
 Non-atomically increment the "infinity" bucket.
 
void Reset () noexcept
 Reset all buckets to zero.
 
HistogramView GetView () const &noexcept
 Allows reading the histogram.
 

Member Function Documentation

◆ Add()

void utils::statistics::HistogramAggregator::Add ( HistogramView other)

Add the other histogram to the current one.

Bucket borders in this and other must be either identical, or bucket borders in this must be a strict subset of bucket borders in other.

Writes to *this are non-atomic.


The documentation for this class was generated from the following file: