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

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

Detailed Description

The value of a metric.

Cheap to copy, expected to be passed around by value.

Definition at line 20 of file metric_value.hpp.

Public Types

using RawType = std::variant<std::int64_t, double, Rate, HistogramView>
 

Public Member Functions

 MetricValue (const MetricValue &)=default
 
MetricValueoperator= (const MetricValue &)=default
 
bool operator== (const MetricValue &other) const noexcept
 
bool operator!= (const MetricValue &other) const noexcept
 
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 Rate metric.
 
bool IsRate () const noexcept
 Returns whether metric is Rate metric.
 
HistogramView AsHistogram () const
 Retrieve the value of a HistogramView metric.
 
bool IsHistogram () const noexcept
 Returns whether metric is HistogramView metric.
 
template<typename VisitorFunc >
decltype(autoVisit (VisitorFunc visitor) const
 Calls visitor with either a std::int64_t or a double value.
 

Member Typedef Documentation

◆ RawType

using utils::statistics::MetricValue::RawType = std::variant<std::int64_t, double, Rate, HistogramView>

Definition at line 22 of file metric_value.hpp.

Member Function Documentation

◆ AsFloat()

double utils::statistics::MetricValue::AsFloat ( ) const
inline

Retrieve the value of a floating-point metric.

Exceptions
std::exceptionon type mismatch.

Definition at line 42 of file metric_value.hpp.

◆ AsHistogram()

HistogramView utils::statistics::MetricValue::AsHistogram ( ) const
inline

Retrieve the value of a HistogramView metric.

Exceptions
std::exceptionon type mismatch.

Definition at line 53 of file metric_value.hpp.

◆ AsInt()

std::int64_t utils::statistics::MetricValue::AsInt ( ) const
inline

Retrieve the value of an integer metric.

Exceptions
std::exceptionon type mismatch.

Definition at line 38 of file metric_value.hpp.

◆ AsRate()

Rate utils::statistics::MetricValue::AsRate ( ) const
inline

Retrieve the value of a Rate metric.

Exceptions
std::exceptionon type mismatch.

Definition at line 46 of file metric_value.hpp.

◆ IsHistogram()

bool utils::statistics::MetricValue::IsHistogram ( ) const
inlinenoexcept

Returns whether metric is HistogramView metric.

Definition at line 56 of file metric_value.hpp.

◆ IsRate()

bool utils::statistics::MetricValue::IsRate ( ) const
inlinenoexcept

Returns whether metric is Rate metric.

Definition at line 49 of file metric_value.hpp.

◆ operator!=()

bool utils::statistics::MetricValue::operator!= ( const MetricValue & other) const
inlinenoexcept

Definition at line 32 of file metric_value.hpp.

◆ operator==()

bool utils::statistics::MetricValue::operator== ( const MetricValue & other) const
inlinenoexcept

Definition at line 28 of file metric_value.hpp.

◆ Visit()

template<typename VisitorFunc >
decltype(auto) utils::statistics::MetricValue::Visit ( VisitorFunc visitor) const
inline

Calls visitor with either a std::int64_t or a double value.

Returns
Whatever visitor returns.

Definition at line 63 of file metric_value.hpp.


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