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/Meter.h>
8
9#include <string>
10
11namespace beast::insight {
12
24{
25public:
27
28 virtual ~Collector() = 0;
29
43 template <class Handler>
44 Hook
45 makeHook(Handler handler)
46 {
47 return makeHook(HookImpl::HandlerType(handler));
48 }
49
50 virtual Hook
51 makeHook(HookImpl::HandlerType const& handler) = 0;
53
58 virtual Counter
59 makeCounter(std::string const& name) = 0;
60
62 makeCounter(std::string const& prefix, std::string const& name)
63 {
64 if (prefix.empty())
65 return makeCounter(name);
66 return makeCounter(prefix + "." + name);
67 }
68
69
74 virtual Event
75 makeEvent(std::string const& name) = 0;
76
77 Event
78 makeEvent(std::string const& prefix, std::string const& name)
79 {
80 if (prefix.empty())
81 return makeEvent(name);
82 return makeEvent(prefix + "." + name);
83 }
84
85
90 virtual Gauge
91 makeGauge(std::string const& name) = 0;
92
93 Gauge
94 makeGauge(std::string const& prefix, std::string const& name)
95 {
96 if (prefix.empty())
97 return makeGauge(name);
98 return makeGauge(prefix + "." + name);
99 }
100
101
106 virtual Meter
107 makeMeter(std::string const& name) = 0;
108
109 Meter
110 makeMeter(std::string const& prefix, std::string const& name)
111 {
112 if (prefix.empty())
113 return makeMeter(name);
114 return makeMeter(prefix + "." + name);
115 }
116
117};
118
119} // namespace beast::insight
Interface for a manager that allows collection of metrics.
Definition Collector.h:24
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:78
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:45
Gauge makeGauge(std::string const &prefix, std::string const &name)
Definition Collector.h:94
virtual Hook makeHook(HookImpl::HandlerType const &handler)=0
Counter makeCounter(std::string const &prefix, std::string const &name)
Definition Collector.h:62
std::shared_ptr< Collector > ptr
Definition Collector.h:26
Meter makeMeter(std::string const &prefix, std::string const &name)
Definition Collector.h:110
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:19
A metric for reporting event timing.
Definition Event.h:21
A metric for measuring an integral value.
Definition Gauge.h:20
std::function< void(void)> HandlerType
Definition HookImpl.h:11
A reference to a handler for performing polled collection.
Definition Hook.h:12
A metric for measuring an integral value.
Definition Meter.h:18
T empty(T... args)