Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
MetricBuilder.hpp
1#pragma once
2
3#include "util/prometheus/MetricBase.hpp"
4
5#include <cstdint>
6#include <memory>
7#include <string>
8#include <vector>
9
10namespace util::prometheus {
11
16 virtual ~MetricBuilderInterface() = default;
17
28 virtual std::unique_ptr<MetricBase>
30 std::string name,
31 std::string labelsString,
32 MetricType type,
33 std::vector<std::int64_t> const& buckets = {}
34 ) = 0;
35
46 virtual std::unique_ptr<MetricBase>
48 std::string name,
49 std::string labelsString,
50 MetricType type,
51 std::vector<double> const& buckets
52 ) = 0;
53};
54
59public:
60 std::unique_ptr<MetricBase>
62 std::string name,
63 std::string labelsString,
64 MetricType type,
65 std::vector<std::int64_t> const& buckets = {}
66 ) override;
67
68 std::unique_ptr<MetricBase>
70 std::string name,
71 std::string labelsString,
72 MetricType type,
73 std::vector<double> const& buckets
74 ) override;
75
76private:
77 static std::unique_ptr<MetricBase>
78 makeMetric(std::string name, std::string labelsString, MetricType type);
79
80 template <typename ValueType>
81 requires std::same_as<ValueType, std::int64_t> || std::same_as<ValueType, double>
82 std::unique_ptr<MetricBase>
83 makeHistogram(
84 std::string name,
85 std::string labelsString,
86 MetricType type,
87 std::vector<ValueType> const& buckets
88 );
89};
90
91} // namespace util::prometheus
Implementation for building a metric.
Definition MetricBuilder.hpp:58
std::unique_ptr< MetricBase > operator()(std::string name, std::string labelsString, MetricType type, std::vector< std::int64_t > const &buckets={}) override
Create a metric.
Definition MetricBuilder.cpp:19
Interface to create a metric.
Definition MetricBuilder.hpp:15
virtual std::unique_ptr< MetricBase > operator()(std::string name, std::string labelsString, MetricType type, std::vector< double > const &buckets)=0
Create a metric double based histogram.
virtual std::unique_ptr< MetricBase > operator()(std::string name, std::string labelsString, MetricType type, std::vector< std::int64_t > const &buckets={})=0
Create a metric.