rippled
Loading...
Searching...
No Matches
Collector.h
1//------------------------------------------------------------------------------
2/*
3 This file is part of Beast: https://github.com/vinniefalco/Beast
4 Copyright 2013, Vinnie Falco <vinnie.falco@gmail.com>
5
6 Permission to use, copy, modify, and/or distribute this software for any
7 purpose with or without fee is hereby granted, provided that the above
8 copyright notice and this permission notice appear in all copies.
9
10 THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17*/
18//==============================================================================
19
20#ifndef BEAST_INSIGHT_COLLECTOR_H_INCLUDED
21#define BEAST_INSIGHT_COLLECTOR_H_INCLUDED
22
23#include <xrpl/beast/insight/Counter.h>
24#include <xrpl/beast/insight/Event.h>
25#include <xrpl/beast/insight/Gauge.h>
26#include <xrpl/beast/insight/Hook.h>
27#include <xrpl/beast/insight/Meter.h>
28
29#include <string>
30
31namespace beast {
32namespace insight {
33
45{
46public:
48
49 virtual ~Collector() = 0;
50
64 template <class Handler>
65 Hook
66 make_hook(Handler handler)
67 {
68 return make_hook(HookImpl::HandlerType(handler));
69 }
70
71 virtual Hook
72 make_hook(HookImpl::HandlerType const& handler) = 0;
79 virtual Counter
80 make_counter(std::string const& name) = 0;
81
83 make_counter(std::string const& prefix, std::string const& name)
84 {
85 if (prefix.empty())
86 return make_counter(name);
87 return make_counter(prefix + "." + name);
88 }
95 virtual Event
96 make_event(std::string const& name) = 0;
97
98 Event
99 make_event(std::string const& prefix, std::string const& name)
100 {
101 if (prefix.empty())
102 return make_event(name);
103 return make_event(prefix + "." + name);
104 }
111 virtual Gauge
112 make_gauge(std::string const& name) = 0;
113
114 Gauge
115 make_gauge(std::string const& prefix, std::string const& name)
116 {
117 if (prefix.empty())
118 return make_gauge(name);
119 return make_gauge(prefix + "." + name);
120 }
127 virtual Meter
128 make_meter(std::string const& name) = 0;
129
130 Meter
131 make_meter(std::string const& prefix, std::string const& name)
132 {
133 if (prefix.empty())
134 return make_meter(name);
135 return make_meter(prefix + "." + name);
136 }
138};
139
140} // namespace insight
141} // namespace beast
142
143#endif
Interface for a manager that allows collection of metrics.
Definition Collector.h:45
virtual Gauge make_gauge(std::string const &name)=0
Create a gauge with the specified name.
Meter make_meter(std::string const &prefix, std::string const &name)
Definition Collector.h:131
Counter make_counter(std::string const &prefix, std::string const &name)
Definition Collector.h:83
virtual Hook make_hook(HookImpl::HandlerType const &handler)=0
Gauge make_gauge(std::string const &prefix, std::string const &name)
Definition Collector.h:115
virtual Counter make_counter(std::string const &name)=0
Create a counter with the specified name.
virtual Event make_event(std::string const &name)=0
Create an event with the specified name.
Event make_event(std::string const &prefix, std::string const &name)
Definition Collector.h:99
Hook make_hook(Handler handler)
Create a hook.
Definition Collector.h:66
virtual Meter make_meter(std::string const &name)=0
Create a meter with the specified name.
A metric for measuring an integral value.
Definition Counter.h:39
A metric for reporting event timing.
Definition Event.h:41
A metric for measuring an integral value.
Definition Gauge.h:40
A reference to a handler for performing polled collection.
Definition Hook.h:32
A metric for measuring an integral value.
Definition Meter.h:38
T empty(T... args)