userver: utils::statistics::MetricValue Class Reference
⚠️ This is the documentation for an old userver version. Click here to switch to the latest version.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages Concepts
utils::statistics::MetricValue Class Referencefinal

The value of a metric. Only integer and floating-point metrics are allowed. More...

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

Public Types

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

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.
 
template<typename VisitorFunc >
decltype(autoVisit (VisitorFunc visitor) const
 Calls visitor with either a std::int64_t or a double value.
 

Detailed Description

The value of a metric. Only integer and floating-point metrics are allowed.

Definition at line 17 of file metric_value.hpp.

Member Typedef Documentation

◆ RawType

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

Definition at line 19 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 38 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 34 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 42 of file metric_value.hpp.

◆ IsRate()

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

Returns whether metric is Rate metric.

Definition at line 45 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.

◆ operator==()

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

Definition at line 24 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 50 of file metric_value.hpp.


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