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
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 
82  Counter
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
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:66
beast::insight::Collector::make_counter
Counter make_counter(std::string const &prefix, std::string const &name)
Definition: Collector.h:83
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:115
beast::insight::Event
A metric for reporting event timing.
Definition: Event.h:40
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:131
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:99
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:641
string