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

constexpr MetricValue () noexcept
 Creates an unspecified metric value.
 
 MetricValue (const MetricValue &)=default
 
MetricValueoperator= (const MetricValue &)=default
 
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.
 
constexpr MetricValue (std::int64_t value) noexcept
 
constexpr MetricValue (double value) noexcept
 
constexpr MetricValue (Rate value) noexcept
 
constexpr MetricValue (HistogramView value) noexcept
 

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.

Constructor & Destructor Documentation

◆ MetricValue() [1/5]

constexpr utils::statistics::MetricValue::MetricValue ( )
inlineconstexprnoexcept

Creates an unspecified metric value.

Definition at line 25 of file metric_value.hpp.

◆ MetricValue() [2/5]

constexpr utils::statistics::MetricValue::MetricValue ( std::int64_t value)
inlineconstexprnoexcept

Constructs MetricValue for tests.

Definition at line 29 of file metric_value.hpp.

◆ MetricValue() [3/5]

constexpr utils::statistics::MetricValue::MetricValue ( double value)
inlineconstexprnoexcept

Definition at line 31 of file metric_value.hpp.

◆ MetricValue() [4/5]

constexpr utils::statistics::MetricValue::MetricValue ( Rate value)
inlineconstexprnoexcept

Definition at line 33 of file metric_value.hpp.

◆ MetricValue() [5/5]

constexpr utils::statistics::MetricValue::MetricValue ( HistogramView value)
inlineconstexprnoexcept

Definition at line 35 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 52 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 63 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 48 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 56 of file metric_value.hpp.

◆ IsHistogram()

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

Returns whether metric is HistogramView metric.

Definition at line 66 of file metric_value.hpp.

◆ IsRate()

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

Returns whether metric is Rate metric.

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

Friends And Related Symbol Documentation

◆ operator!=

bool operator!= ( const MetricValue & lhs,
const MetricValue & rhs )
friend

Definition at line 44 of file metric_value.hpp.

◆ operator==

bool operator== ( const MetricValue & lhs,
const MetricValue & rhs )
friend

Definition at line 42 of file metric_value.hpp.


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