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
37 friend OStream&
38 operator<<(OStream& stream, MetricBase const& metricBase);
39
44 std::string const&
45 name() const;
46
51 std::string const&
52 labelsString() const;
53
54protected:
60 virtual void
61 serializeValue(OStream& stream) const = 0;
62
63private:
64 std::string name_;
65 std::string labelsString_;
66};
67
68enum class MetricType {
69 CounterInt,
70 CounterDouble,
71 GaugeInt,
72 GaugeDouble,
73 HistogramInt,
74 HistogramDouble,
75 Summary
76};
77
78char const*
79toString(MetricType type);
80
81} // 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
std::string toString(ripple::LedgerHeader const &info)
A helper function that converts a ripple::LedgerHeader to a string representation.
Definition LedgerUtils.hpp:245