9#include <userver/utils/statistics/rate.hpp>
11USERVER_NAMESPACE_BEGIN
13namespace utils::statistics {
17class MetricValue
final {
19 using RawType = std::variant<std::int64_t,
double,
Rate>;
21 MetricValue(
const MetricValue&) =
default;
22 MetricValue& operator=(
const MetricValue&) =
default;
24 bool operator==(
const MetricValue& other)
const noexcept {
25 return value_ == other.value_;
28 bool operator!=(
const MetricValue& other)
const noexcept {
29 return value_ != other.value_;
34 std::int64_t
AsInt()
const {
return std::get<std::int64_t>(value_); }
38 double AsFloat()
const {
return std::get<
double>(value_); }
45 bool IsRate()
const noexcept {
return std::holds_alternative<Rate>(value_); }
49 template <
typename VisitorFunc>
50 decltype(
auto)
Visit(VisitorFunc visitor)
const {
51 return std::visit(visitor, value_);
55 MetricValue()
noexcept : value_(std::int64_t{0}) {}
57 explicit MetricValue(RawType value)
noexcept : value_(value) {}