Kagome
Polkadot Runtime Engine in C++17
metrics.hpp
Go to the documentation of this file.
1 
6 #ifndef KAGOME_CORE_METRICS_METRICS_HPP
7 #define KAGOME_CORE_METRICS_METRICS_HPP
8 
9 #include <memory>
10 #include <vector>
11 
12 #include "metrics/registry.hpp"
13 
14 namespace kagome::metrics {
15  using RegistryPtr = std::unique_ptr<Registry>;
16 
17  // the function recommended to use to create a registry of the chosen
18  // implementation
20 
27  class Counter {
28  public:
29  virtual ~Counter() = default;
30 
34  virtual void inc() = 0;
35 
39  virtual void inc(double val) = 0;
40  };
41 
49  class Gauge {
50  public:
51  virtual ~Gauge() = default;
52 
56  virtual void inc() = 0;
57 
61  virtual void inc(double val) = 0;
62 
66  virtual void dec() = 0;
67 
71  virtual void dec(double val) = 0;
72 
76  virtual void set(double val) = 0;
77 
78  template <typename T>
79  void set(T val) {
80  set(static_cast<double>(val));
81  }
82  };
83 
91  class Summary {
92  public:
93  virtual ~Summary() = default;
94 
98  virtual void observe(const double value) = 0;
99  };
100 
108  class Histogram {
109  public:
110  virtual ~Histogram() = default;
111 
115  virtual void observe(const double value) = 0;
116  };
117 } // namespace kagome::metrics
118 
119 #endif // KAGOME_CORE_METRICS_METRICS_HPP
A histogram metric to represent aggregatable distributions of events.
Definition: metrics.hpp:108
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
virtual void inc()=0
Increment the counter by 1.
virtual ~Counter()=default
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