rippled
NullCollector.cpp
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 #include <ripple/beast/insight/NullCollector.h>
21 
22 namespace beast {
23 namespace insight {
24 
25 namespace detail {
26 
27 class NullHookImpl : public HookImpl
28 {
29 public:
30  explicit NullHookImpl() = default;
31 
32 private:
34  operator=(NullHookImpl const&);
35 };
36 
37 //------------------------------------------------------------------------------
38 
40 {
41 public:
42  explicit NullCounterImpl() = default;
43 
44  void increment(value_type) override
45  {
46  }
47 
48 private:
50  operator=(NullCounterImpl const&);
51 };
52 
53 //------------------------------------------------------------------------------
54 
55 class NullEventImpl : public EventImpl
56 {
57 public:
58  explicit NullEventImpl() = default;
59 
60  void
61  notify(value_type const&) override
62  {
63  }
64 
65 private:
67  operator=(NullEventImpl const&);
68 };
69 
70 //------------------------------------------------------------------------------
71 
72 class NullGaugeImpl : public GaugeImpl
73 {
74 public:
75  explicit NullGaugeImpl() = default;
76 
77  void set(value_type) override
78  {
79  }
80 
81  void increment(difference_type) override
82  {
83  }
84 
85 private:
87  operator=(NullGaugeImpl const&);
88 };
89 
90 //------------------------------------------------------------------------------
91 
92 class NullMeterImpl : public MeterImpl
93 {
94 public:
95  explicit NullMeterImpl() = default;
96 
97  void increment(value_type) override
98  {
99  }
100 
101 private:
103  operator=(NullMeterImpl const&);
104 };
105 
106 //------------------------------------------------------------------------------
107 
109 {
110 private:
111 public:
112  NullCollectorImp() = default;
113 
114  ~NullCollectorImp() = default;
115 
116  Hook
118  {
119  return Hook(std::make_shared<detail::NullHookImpl>());
120  }
121 
122  Counter
123  make_counter(std::string const&) override
124  {
125  return Counter(std::make_shared<detail::NullCounterImpl>());
126  }
127 
128  Event
129  make_event(std::string const&) override
130  {
131  return Event(std::make_shared<detail::NullEventImpl>());
132  }
133 
134  Gauge
135  make_gauge(std::string const&) override
136  {
137  return Gauge(std::make_shared<detail::NullGaugeImpl>());
138  }
139 
140  Meter
141  make_meter(std::string const&) override
142  {
143  return Meter(std::make_shared<detail::NullMeterImpl>());
144  }
145 };
146 
147 } // namespace detail
148 
149 //------------------------------------------------------------------------------
150 
153 {
154  return std::make_shared<detail::NullCollectorImp>();
155 }
156 
157 } // namespace insight
158 } // namespace beast
beast::insight::detail::NullGaugeImpl
Definition: NullCollector.cpp:72
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::HookImpl
Definition: HookImpl.h:29
beast::insight::CounterImpl
Definition: CounterImpl.h:31
beast::insight::detail::NullGaugeImpl::NullGaugeImpl
NullGaugeImpl()=default
beast::insight::detail::NullMeterImpl::NullMeterImpl
NullMeterImpl()=default
std::chrono::milliseconds
beast::insight::detail::NullHookImpl::operator=
NullHookImpl & operator=(NullHookImpl const &)
beast::insight::detail::NullCollectorImp
Definition: NullCollector.cpp:108
std::function< void(void)>
beast::insight::detail::NullCollectorImp::make_gauge
Gauge make_gauge(std::string const &) override
Create a gauge with the specified name.
Definition: NullCollector.cpp:135
beast::insight::detail::NullEventImpl::operator=
NullEventImpl & operator=(NullEventImpl const &)
beast::insight::MeterImpl
Definition: MeterImpl.h:31
beast::insight::detail::NullMeterImpl::operator=
NullMeterImpl & operator=(NullMeterImpl const &)
beast::insight::detail::NullCollectorImp::make_event
Event make_event(std::string const &) override
Create an event with the specified name.
Definition: NullCollector.cpp:129
beast::insight::detail::NullEventImpl
Definition: NullCollector.cpp:55
beast::insight::NullCollector
A Collector which does not collect metrics.
Definition: NullCollector.h:29
beast::insight::detail::NullHookImpl::NullHookImpl
NullHookImpl()=default
beast::insight::detail::NullCollectorImp::~NullCollectorImp
~NullCollectorImp()=default
beast::insight::detail::NullCollectorImp::make_hook
Hook make_hook(HookImpl::HandlerType const &) override
Definition: NullCollector.cpp:117
beast::insight::detail::NullCounterImpl::NullCounterImpl
NullCounterImpl()=default
beast::insight::Event
A metric for reporting event timing.
Definition: Event.h:40
beast::insight::GaugeImpl
Definition: GaugeImpl.h:31
beast::insight::detail::NullCollectorImp::NullCollectorImp
NullCollectorImp()=default
beast::insight::detail::NullCollectorImp::make_counter
Counter make_counter(std::string const &) override
Create a counter with the specified name.
Definition: NullCollector.cpp:123
beast::insight::detail::NullHookImpl
Definition: NullCollector.cpp:27
std::int64_t
beast::insight::detail::NullGaugeImpl::operator=
NullGaugeImpl & operator=(NullGaugeImpl const &)
beast::insight::Gauge
A metric for measuring an integral value.
Definition: Gauge.h:39
beast::insight::detail::NullCounterImpl
Definition: NullCollector.cpp:39
beast::insight::detail::NullEventImpl::notify
void notify(value_type const &) override
Definition: NullCollector.cpp:61
beast::insight::EventImpl
Definition: EventImpl.h:31
beast::insight::detail::NullCounterImpl::increment
void increment(value_type) override
Definition: NullCollector.cpp:44
beast::insight::detail::NullCounterImpl::operator=
NullCounterImpl & operator=(NullCounterImpl const &)
beast::insight::detail::NullGaugeImpl::increment
void increment(difference_type) override
Definition: NullCollector.cpp:81
beast::insight::detail::NullMeterImpl
Definition: NullCollector.cpp:92
beast::insight::detail::NullGaugeImpl::set
void set(value_type) override
Definition: NullCollector.cpp:77
beast::insight::Hook
A reference to a handler for performing polled collection.
Definition: Hook.h:31
beast::insight::detail::NullEventImpl::NullEventImpl
NullEventImpl()=default
beast::insight::NullCollector::New
static std::shared_ptr< Collector > New()
Definition: NullCollector.cpp:152
beast::insight::detail::NullCollectorImp::make_meter
Meter make_meter(std::string const &) override
Create a meter with the specified name.
Definition: NullCollector.cpp:141
beast::insight::detail::NullMeterImpl::increment
void increment(value_type) override
Definition: NullCollector.cpp:97
beast
Definition: base_uint.h:641