Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MetricBase.hpp
1#pragma once
2
3#include "util/prometheus/OStream.hpp"
4
5#include <string>
6
7namespace util::prometheus {
8
13public:
21 MetricBase(std::string name, std::string labelsString);
22
23 MetricBase(MetricBase const&) = delete;
24 MetricBase(MetricBase&&) = default;
26 operator=(MetricBase const&) = delete;
28 operator=(MetricBase&&) = default;
29 virtual ~MetricBase() = default;
30
38 friend OStream&
39 operator<<(OStream& stream, MetricBase const& metricBase);
40
45 [[nodiscard]] std::string const&
46 name() const;
47
52 [[nodiscard]] std::string const&
53 labelsString() const;
54
55protected:
61 virtual void
62 serializeValue(OStream& stream) const = 0;
63
64private:
65 std::string name_;
66 std::string labelsString_;
67};
68
81
88char const*
90
91} // namespace util::prometheus
friend OStream & operator<<(OStream &stream, MetricBase const &metricBase)
Serialize the metric to a string in Prometheus format.
Definition MetricBase.cpp:17
MetricBase(std::string name, std::string labelsString)
Construct a new MetricBase object.
Definition MetricBase.cpp:11
std::string const & name() const
Get the name of the metric.
Definition MetricBase.cpp:48
virtual void serializeValue(OStream &stream) const =0
Interface to serialize the value of the metric.
std::string const & labelsString() const
Get the labels of the metric in serialized format, e.g. {name="value",name2="value2"}...
Definition MetricBase.cpp:54
A stream that can optionally compress its data.
Definition OStream.hpp:12
Prometheus metrics: counters, gauges, histograms and their registry and serialization.
Definition Bool.hpp:12
AnyCounter< std::uint64_t > CounterInt
A prometheus counter metric implementation with a value of type std::int64_t.
Definition Counter.hpp:114
char const * toString(MetricType type)
Get the Prometheus type name of a metric type, as used in the # TYPE line.
Definition MetricBase.cpp:24
AnyCounter< double > CounterDouble
A prometheus counter metric implementation with a value of type double.
Definition Counter.hpp:119
AnyGauge< std::int64_t > GaugeInt
Alias for a gauge with a 64-bit integer value.
Definition Gauge.hpp:127
MetricType
The kind and value type of a Prometheus metric.
Definition MetricBase.hpp:72
@ Summary
Summary (not currently supported by the metric builder).
Definition MetricBase.hpp:79
AnyHistogram< double > HistogramDouble
Histogram of floating point values.
Definition Histogram.hpp:135
AnyGauge< double > GaugeDouble
Alias for a gauge with a double value.
Definition Gauge.hpp:132
AnyHistogram< std::int64_t > HistogramInt
Histogram of integer values.
Definition Histogram.hpp:134