23struct fmt::formatter<USERVER_NAMESPACE::utils::statistics::LabelView> {
24 constexpr static auto parse(format_parse_context& ctx) {
return ctx.begin(); }
26 template <
typename FormatContext>
27 auto format(USERVER_NAMESPACE::utils::statistics::LabelView value, FormatContext& ctx)
const {
28 return fmt::format_to(ctx.out(),
"{}={}", value.Name(), value.Value());
33struct fmt::formatter<USERVER_NAMESPACE::utils::statistics::Label>
34 :
public fmt::formatter<USERVER_NAMESPACE::utils::statistics::LabelView> {
35 template <
typename FormatContext>
36 auto format(
const USERVER_NAMESPACE::utils::statistics::Label& value, FormatContext& ctx)
const {
37 return formatter<USERVER_NAMESPACE::utils::statistics::LabelView>::format(
38 USERVER_NAMESPACE::utils::statistics::LabelView{value},
45struct fmt::formatter<USERVER_NAMESPACE::utils::statistics::LabelsSpan> {
46 constexpr static auto parse(format_parse_context& ctx) {
return ctx.begin(); }
48 template <
typename FormatContext>
49 auto format(USERVER_NAMESPACE::utils::statistics::LabelsSpan value, FormatContext& ctx)
const {
50 return fmt::format_to(ctx.out(),
"{}", fmt::join(value,
";"));
55class fmt::formatter<USERVER_NAMESPACE::utils::statistics::
Rate> {
57 constexpr auto parse(format_parse_context& ctx) {
return rate_format_.parse(ctx); }
59 template <
typename FormatCtx>
60 auto format(
const USERVER_NAMESPACE::utils::statistics::
Rate& rate, FormatCtx& ctx)
const {
61 return rate_format_.format(rate.value, ctx);
65 fmt::formatter<USERVER_NAMESPACE::utils::statistics::
Rate::ValueType> rate_format_;
69struct fmt::formatter<USERVER_NAMESPACE::utils::statistics::HistogramView> {
71 constexpr auto parse(format_parse_context& ctx) {
return ctx.begin(); }
73 template <
typename FormatCtx>
74 auto format(USERVER_NAMESPACE::utils::statistics::HistogramView histogram, FormatCtx& ctx)
const {
76 for (std::size_t i = 0; i < bucket_count; ++i) {
78 ctx.advance_to(fmt::format_to(ctx.out(),
","));
80 ctx.advance_to(fmt::format_to(ctx.out(),
"[inf]={}", histogram
.GetValueAtInf()));
86class fmt::formatter<USERVER_NAMESPACE::utils::statistics::MetricValue> {
88 constexpr auto parse(format_parse_context& ctx) {
90 const auto max = [](
auto a,
auto b) {
return a > b ? a : b; };
92 int_format_.parse(ctx),
93 max(float_format_.parse(ctx), max(rate_format_.parse(ctx), histogram_format_.parse(ctx)))
97 template <
typename FormatContext>
98 auto format(USERVER_NAMESPACE::utils::statistics::MetricValue value, FormatContext& ctx)
const {
99 return value.Visit(USERVER_NAMESPACE::utils::
Overloaded{
100 [&](std::int64_t x) {
return int_format_.format(x, ctx); },
101 [&](USERVER_NAMESPACE::utils::statistics::
Rate x) {
return rate_format_.format(x.value, ctx); },
102 [&](
double x) {
return float_format_.format(x, ctx); },
103 [&](USERVER_NAMESPACE::utils::statistics::HistogramView x) {
return histogram_format_.format(x, ctx); }
109 fmt::formatter<std::int64_t> int_format_;
110 fmt::formatter<USERVER_NAMESPACE::utils::statistics::
Rate::ValueType> rate_format_;
111 fmt::formatter<
double> float_format_;
112 fmt::formatter<USERVER_NAMESPACE::utils::statistics::HistogramView> histogram_format_;