userver
C++ Async Framework
Loading...
Searching...
No Matches
histogram_view.hpp
Go to the documentation of this file.
1
#
pragma
once
2
3
/// @file userver/utils/statistics/histogram_view.hpp
4
/// @brief @copybrief utils::statistics::HistogramView
5
6
#
include
<
cstddef
>
7
#
include
<
cstdint
>
8
#
include
<
type_traits
>
9
10
USERVER_NAMESPACE_BEGIN
11
12
namespace
utils
::statistics {
13
14
class
Writer;
15
16
namespace
impl::histogram {
17
struct
Bucket;
18
struct
Access;
19
}
// namespace impl::histogram
20
21
/// @brief The non-owning reader API for "histogram" metrics.
22
///
23
/// @see utils::statistics::Histogram for details on semantics
24
///
25
/// HistogramView is cheap to copy, expected to be passed around by value.
26
class
HistogramView
final
{
27
public
:
28
// trivially copyable
29
constexpr
HistogramView(
const
HistogramView&)
noexcept
=
default
;
30
constexpr
HistogramView& operator=(
const
HistogramView&)
noexcept
=
default
;
31
32
/// Returns the number of "normal" (non-"infinity") buckets.
33
std::size_t
GetBucketCount
()
const
noexcept
;
34
35
/// Returns the upper bucket boundary for the given bucket.
36
double
GetUpperBoundAt
(std::size_t index)
const
;
37
38
/// Returns the occurrence count for the given bucket.
39
std::
uint64_t
GetValueAt
(std::size_t index)
const
;
40
41
/// Returns the occurrence count for the "infinity" bucket
42
/// (greater than the largest bucket boundary).
43
std::
uint64_t
GetValueAtInf
()
const
noexcept
;
44
45
/// Returns the sum of counts from all buckets.
46
std::
uint64_t
GetTotalCount
()
const
noexcept
;
47
48
/// Returns sum of values from the given bucket.
49
double
GetSumAt
(std::size_t index)
const
;
50
51
// Returns sum of values from the "infinity" bucket
52
/// (greater than the largest bucket boundary).
53
double
GetSumAtInf
()
const
noexcept
;
54
55
/// Returns sum of values from all buckets.
56
double
GetTotalSum
()
const
noexcept
;
57
58
private
:
59
friend
struct
impl::histogram::Access;
60
61
constexpr
explicit
HistogramView(
const
impl::histogram::Bucket& buckets)
noexcept
: buckets_(&buckets) {}
62
63
const
impl::histogram::Bucket* buckets_;
64
};
65
66
/// Compares equal if bounds are close and values are equal.
67
bool
operator
==(HistogramView lhs, HistogramView rhs)
noexcept
;
68
69
/// @overload
70
bool
operator
!=(HistogramView lhs, HistogramView rhs)
noexcept
;
71
72
}
// namespace utils::statistics
73
74
USERVER_NAMESPACE_END
userver
utils
statistics
histogram_view.hpp
Generated on Mon Sep 29 2025 12:37:37 for userver by
Doxygen
1.13.2