Kagome
Polkadot Runtime Engine in C++17
registry_impl.cpp
Go to the documentation of this file.
1 
7 
8 #include "metrics/handler.hpp"
9 #include "metrics/registry.hpp"
10 
11 namespace kagome::metrics {
12 
14  return std::make_unique<PrometheusRegistry>();
15  }
16 
18  handler.registerCollectable(*this);
19  }
20 
22  const std::string &name,
23  const std::string &help,
24  const std::map<std::string, std::string> &labels) {
25  registerFamily<Counter>(name, help, labels);
26  }
27 
29  const std::string &name,
30  const std::string &help,
31  const std::map<std::string, std::string> &labels) {
32  registerFamily<Gauge>(name, help, labels);
33  }
34 
36  const std::string &name,
37  const std::string &help,
38  const std::map<std::string, std::string> &labels) {
39  registerFamily<Histogram>(name, help, labels);
40  }
41 
43  const std::string &name,
44  const std::string &help,
45  const std::map<std::string, std::string> &labels) {
46  registerFamily<Summary>(name, help, labels);
47  }
48 
50  const std::string &name,
51  const std::map<std::string, std::string> &labels) {
52  return registerMetric<Counter>(name, labels);
53  }
54 
56  const std::string &name,
57  const std::map<std::string, std::string> &labels) {
58  return registerMetric<Gauge>(name, labels);
59  }
60 
62  const std::string &name,
63  const std::vector<double> &bucket_boundaries,
64  const std::map<std::string, std::string> &labels) {
65  return registerMetric<Histogram>(name, labels, bucket_boundaries);
66  }
67 
69  const std::string &name,
70  const std::vector<std::pair<double, double>> &quantiles,
71  std::chrono::milliseconds max_age,
72  int age_buckets,
73  const std::map<std::string, std::string> &labels) {
74  prometheus::Summary::Quantiles q;
75  for (const auto &p : quantiles) {
76  q.push_back({p.first, p.second});
77  }
78  return registerMetric<Summary>(name, labels, q, max_age, age_buckets);
79  }
80 
81 } // namespace kagome::metrics
an interface to add request handler for metrics::Exposer implementation generally will contain metric...
Definition: handler.hpp:22
void registerSummaryFamily(const std::string &name, const std::string &help, const std::map< std::string, std::string > &labels) override
Summary * registerSummaryMetric(const std::string &name, const std::vector< std::pair< double, double >> &quantiles, std::chrono::milliseconds max_age, int age_buckets, const std::map< std::string, std::string > &labels) override
create summary metrics object
void setHandler(Handler &handler) override
A histogram metric to represent aggregatable distributions of events.
Definition: metrics.hpp:108
virtual void registerCollectable(Registry &registry)=0
registers general type metrics registry for metrics collection
void registerHistogramFamily(const std::string &name, const std::string &help, const std::map< std::string, std::string > &labels) override
void registerGaugeFamily(const std::string &name, const std::string &help, const std::map< std::string, std::string > &labels) override
std::unique_ptr< Registry > RegistryPtr
Definition: metrics.hpp:15
RegistryPtr createRegistry()
A summary metric samples observations over a sliding window of time.
Definition: metrics.hpp:91
Histogram * registerHistogramMetric(const std::string &name, const std::vector< double > &bucket_boundaries, const std::map< std::string, std::string > &labels) override
create histogram metrics object
Counter * registerCounterMetric(const std::string &name, const std::map< std::string, std::string > &labels) override
create counter metrics object
void registerCounterFamily(const std::string &name, const std::string &help, const std::map< std::string, std::string > &labels) override
Gauge * registerGaugeMetric(const std::string &name, const std::map< std::string, std::string > &labels) override
create gauge metrics object
A gauge metric to represent a value that can arbitrarily go up and down.
Definition: metrics.hpp:49
A counter metric to represent a monotonically increasing value.
Definition: metrics.hpp:27