#include <userver/utils/statistics/metric_value.hpp>
The value of a metric.
Cheap to copy, expected to be passed around by value.
A histogram is stored only as a utils::statistics::HistogramView. Its backing storage has to be kept alive separately.
Definition at line 27 of file metric_value.hpp.
Public Types | |
| using | RawType = std::variant<std::int64_t, double, Rate, HistogramView> |
Public Member Functions | |
| constexpr | MetricValue () noexcept |
| Creates an unspecified metric value. | |
| MetricValue (const MetricValue &)=default | |
| MetricValue & | operator= (const MetricValue &)=default |
| bool | EqualsNumerically (const MetricValue &other) const noexcept |
| Numeric comparison of two metric values. | |
| std::int64_t | AsInt () const |
| Retrieve the value of an integer metric. | |
| double | AsFloat () const |
| Retrieve the value of a floating-point metric. | |
| Rate | AsRate () const |
| Retrieve the value of a utils::statistics::Rate metric. | |
| bool | IsRate () const noexcept |
| Returns whether metric is a utils::statistics::Rate metric. | |
| HistogramView | AsHistogram () const |
| Retrieve the value of a utils::statistics::HistogramView metric. | |
| bool | IsHistogram () const noexcept |
| Returns whether metric is a utils::statistics::HistogramView metric. | |
| template<typename VisitorFunc> | |
| decltype(auto) | Visit (VisitorFunc visitor) const |
Calls visitor with the stored value. | |
| constexpr | MetricValue (std::int64_t value) noexcept |
| constexpr | MetricValue (double value) noexcept |
| constexpr | MetricValue (Rate value) noexcept |
| constexpr | MetricValue (HistogramView value) noexcept |
| using utils::statistics::MetricValue::RawType = std::variant<std::int64_t, double, Rate, HistogramView> |
Definition at line 29 of file metric_value.hpp.
|
inlineconstexprnoexcept |
Creates an unspecified metric value.
Definition at line 32 of file metric_value.hpp.
|
inlineconstexprnoexcept |
Constructs utils::statistics::MetricValue for tests.
Definition at line 36 of file metric_value.hpp.
|
inlineconstexprnoexcept |
Definition at line 38 of file metric_value.hpp.
|
inlineconstexprnoexcept |
Definition at line 40 of file metric_value.hpp.
|
inlineconstexprnoexcept |
Definition at line 42 of file metric_value.hpp.
|
inline |
Retrieve the value of a floating-point metric.
| std::exception | on type mismatch. |
Definition at line 71 of file metric_value.hpp.
|
inline |
Retrieve the value of a utils::statistics::HistogramView metric.
| std::exception | on type mismatch. |
Definition at line 82 of file metric_value.hpp.
|
inline |
Retrieve the value of an integer metric.
| std::exception | on type mismatch. |
Definition at line 67 of file metric_value.hpp.
|
inline |
Retrieve the value of a utils::statistics::Rate metric.
| std::exception | on type mismatch. |
Definition at line 75 of file metric_value.hpp.
|
noexcept |
Numeric comparison of two metric values.
std::int64_t, double and utils::statistics::Rate compare as numbers: 4, 4.0 and Rate{4} are equal. A fractional double is not equal to a truncated integer. An integer that is not exactly representable as double is not equal to the rounded value.
utils::statistics::HistogramView compares as a histogram, via utils::statistics::operator==(HistogramView,HistogramView). Bucket sums are ignored. A histogram is not equal to a number.
|
inlinenoexcept |
Returns whether metric is a utils::statistics::HistogramView metric.
Definition at line 85 of file metric_value.hpp.
|
inlinenoexcept |
Returns whether metric is a utils::statistics::Rate metric.
Definition at line 78 of file metric_value.hpp.
|
inline |
Calls visitor with the stored value.
The argument has one of these types:
visitor returns. Definition at line 97 of file metric_value.hpp.
|
friend |
Definition at line 51 of file metric_value.hpp.
|
friend |
Definition at line 49 of file metric_value.hpp.