rippled
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 <ripple/beast/insight/Counter.h>
24 #include <ripple/beast/insight/Event.h>
25 #include <ripple/beast/insight/Gauge.h>
26 #include <ripple/beast/insight/Hook.h>
27 #include <ripple/beast/insight/Meter.h>
28 
29 #include <string>
30 
31 namespace beast {
32 namespace insight {
33 
44 class Collector
45 {
46 public:
48 
49  virtual ~Collector() = 0;
50 
64  template <class Handler>
65  Hook make_hook (Handler handler)
66  {
67  return make_hook (HookImpl::HandlerType (handler));
68  }
69 
70  virtual Hook make_hook (HookImpl::HandlerType const& handler) = 0;
77  virtual Counter make_counter (std::string const& name) = 0;
78 
79  Counter make_counter (std::string const& prefix, std::string const& name)
80  {
81  if (prefix.empty ())
82  return make_counter (name);
83  return make_counter (prefix + "." + name);
84  }
91  virtual Event make_event (std::string const& name) = 0;
92 
93  Event make_event (std::string const& prefix, std::string const& name)
94  {
95  if (prefix.empty ())
96  return make_event (name);
97  return make_event (prefix + "." + name);
98  }
105  virtual Gauge make_gauge (std::string const& name) = 0;
106 
107  Gauge make_gauge (std::string const& prefix, std::string const& name)
108  {
109  if (prefix.empty ())
110  return make_gauge (name);
111  return make_gauge (prefix + "." + name);
112  }
119  virtual Meter make_meter (std::string const& name) = 0;
120 
121  Meter make_meter (std::string const& prefix, std::string const& name)
122  {
123  if (prefix.empty ())
124  return make_meter (name);
125  return make_meter (prefix + "." + name);
126  }
128 };
129 
130 }
131 }
132 
133 #endif
std::string
STL class.
std::shared_ptr< Collector >
beast::insight::Meter
A metric for measuring an integral value.
Definition: Meter.h:37
beast::insight::Counter
A metric for measuring an integral value.
Definition: Counter.h:38
beast::insight::Collector::make_hook
Hook make_hook(Handler handler)
Create a hook.
Definition: Collector.h:65
beast::insight::Collector::make_counter
Counter make_counter(std::string const &prefix, std::string const &name)
Definition: Collector.h:79
std::function< void(void)>
beast::insight::Collector::make_event
virtual Event make_event(std::string const &name)=0
Create an event with the specified name.
beast::insight::Collector::make_meter
virtual Meter make_meter(std::string const &name)=0
Create a meter with the specified name.
beast::insight::Collector::make_gauge
Gauge make_gauge(std::string const &prefix, std::string const &name)
Definition: Collector.h:107
beast::insight::Event
A metric for reporting event timing.
Definition: Event.h:42
beast::insight::Collector::make_gauge
virtual Gauge make_gauge(std::string const &name)=0
Create a gauge with the specified name.
beast::insight::Gauge
A metric for measuring an integral value.
Definition: Gauge.h:39
beast::insight::Collector::make_counter
virtual Counter make_counter(std::string const &name)=0
Create a counter with the specified name.
beast::insight::Collector::make_meter
Meter make_meter(std::string const &prefix, std::string const &name)
Definition: Collector.h:121
std::string::empty
T empty(T... args)
beast::insight::Collector
Interface for a manager that allows collection of metrics.
Definition: Collector.h:44
beast::insight::Collector::make_event
Event make_event(std::string const &prefix, std::string const &name)
Definition: Collector.h:93
beast::insight::Collector::~Collector
virtual ~Collector()=0
beast::insight::Hook
A reference to a handler for performing polled collection.
Definition: Hook.h:31
beast
Definition: base_uint.h:582
string