xrpld
Loading...
Searching...
No Matches
Collector.h
1#pragma once
2
3#include <xrpl/beast/insight/Counter.h>
4#include <xrpl/beast/insight/Event.h>
5#include <xrpl/beast/insight/Gauge.h>
6#include <xrpl/beast/insight/Hook.h>
7#include <xrpl/beast/insight/HookImpl.h>
8#include <xrpl/beast/insight/Meter.h>
9
10#include <memory>
11#include <string>
12
13namespace beast::insight {
14
27{
28public:
30
31 virtual ~Collector() = 0;
32
47 template <class Handler>
48 Hook
49 makeHook(Handler handler)
50 {
51 return makeHook(HookImpl::HandlerType(handler));
52 }
53
54 virtual Hook
55 makeHook(HookImpl::HandlerType const& handler) = 0;
57
63 virtual Counter
64 makeCounter(std::string const& name) = 0;
65
67 makeCounter(std::string const& prefix, std::string const& name)
68 {
69 if (prefix.empty())
70 return makeCounter(name);
71 return makeCounter(prefix + "." + name);
72 }
73
74
80 virtual Event
81 makeEvent(std::string const& name) = 0;
82
83 Event
84 makeEvent(std::string const& prefix, std::string const& name)
85 {
86 if (prefix.empty())
87 return makeEvent(name);
88 return makeEvent(prefix + "." + name);
89 }
90
91
97 virtual Gauge
98 makeGauge(std::string const& name) = 0;
99
100 Gauge
101 makeGauge(std::string const& prefix, std::string const& name)
102 {
103 if (prefix.empty())
104 return makeGauge(name);
105 return makeGauge(prefix + "." + name);
106 }
107
108
114 virtual Meter
115 makeMeter(std::string const& name) = 0;
116
117 Meter
118 makeMeter(std::string const& prefix, std::string const& name)
119 {
120 if (prefix.empty())
121 return makeMeter(name);
122 return makeMeter(prefix + "." + name);
123 }
124
125};
126
127} // namespace beast::insight
Interface for a manager that allows collection of metrics.
Definition Collector.h:27
virtual Event makeEvent(std::string const &name)=0
Create an event with the specified name.
virtual Counter makeCounter(std::string const &name)=0
Create a counter with the specified name.
Event makeEvent(std::string const &prefix, std::string const &name)
Definition Collector.h:84
virtual Meter makeMeter(std::string const &name)=0
Create a meter with the specified name.
Hook makeHook(Handler handler)
Create a hook.
Definition Collector.h:49
Gauge makeGauge(std::string const &prefix, std::string const &name)
Definition Collector.h:101
virtual Hook makeHook(HookImpl::HandlerType const &handler)=0
Counter makeCounter(std::string const &prefix, std::string const &name)
Definition Collector.h:67
std::shared_ptr< Collector > ptr
Definition Collector.h:29
Meter makeMeter(std::string const &prefix, std::string const &name)
Definition Collector.h:118
virtual Gauge makeGauge(std::string const &name)=0
Create a gauge with the specified name.
A metric for measuring an integral value.
Definition Counter.h:20
A metric for reporting event timing.
Definition Event.h:22
A metric for measuring an integral value.
Definition Gauge.h:21
std::function< void(void)> HandlerType
Definition HookImpl.h:11
A reference to a handler for performing polled collection.
Definition Hook.h:14
A metric for measuring an integral value.
Definition Meter.h:19
T empty(T... args)