NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/metrics/noop.h
Go to the documentation of this file.
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3 
4 #pragma once
5 
6 #include "opentelemetry/metrics/async_instruments.h"
7 #include "opentelemetry/metrics/meter.h"
8 #include "opentelemetry/metrics/meter_provider.h"
9 #include "opentelemetry/metrics/observer_result.h"
10 #include "opentelemetry/metrics/sync_instruments.h"
11 #include "opentelemetry/version.h"
12 
14 namespace metrics
15 {
16 
17 template <class T>
18 class NoopCounter : public Counter<T>
19 {
20 public:
22  nostd::string_view /* description */,
23  nostd::string_view /* unit */) noexcept
24  {}
25  void Add(T /* value */) noexcept override {}
26  void Add(T /* value */, const context::Context & /* context */) noexcept override {}
27  void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
28  void Add(T /* value */,
29  const common::KeyValueIterable & /* attributes */,
30  const context::Context & /* context */) noexcept override
31  {}
32 };
33 
34 template <class T>
35 class NoopHistogram : public Histogram<T>
36 {
37 public:
39  nostd::string_view /* description */,
40  nostd::string_view /* unit */) noexcept
41  {}
42  void Record(T /* value */, const context::Context & /* context */) noexcept override {}
43  void Record(T /* value */,
44  const common::KeyValueIterable & /* attributes */,
45  const context::Context & /* context */) noexcept override
46  {}
47 #if OPENTELEMETRY_ABI_VERSION_NO >= 2
48  void Record(T /*value*/,
49  const opentelemetry::common::KeyValueIterable & /*attributes*/) noexcept override
50  {}
51 
52  void Record(T /*value*/) noexcept override {}
53 #endif
54 };
55 
56 template <class T>
58 {
59 public:
61  nostd::string_view /* description */,
62  nostd::string_view /* unit */) noexcept
63  {}
64  ~NoopUpDownCounter() override = default;
65  void Add(T /* value */) noexcept override {}
66  void Add(T /* value */, const context::Context & /* context */) noexcept override {}
67  void Add(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
68  void Add(T /* value */,
69  const common::KeyValueIterable & /* attributes */,
70  const context::Context & /* context */) noexcept override
71  {}
72 };
73 
74 #if OPENTELEMETRY_ABI_VERSION_NO >= 2
75 template <class T>
76 class NoopGauge : public Gauge<T>
77 {
78 public:
79  NoopGauge(nostd::string_view /* name */,
80  nostd::string_view /* description */,
81  nostd::string_view /* unit */) noexcept
82  {}
83  ~NoopGauge() override = default;
84  void Record(T /* value */) noexcept override {}
85  void Record(T /* value */, const context::Context & /* context */) noexcept override {}
86  void Record(T /* value */, const common::KeyValueIterable & /* attributes */) noexcept override {}
87  void Record(T /* value */,
88  const common::KeyValueIterable & /* attributes */,
89  const context::Context & /* context */) noexcept override
90  {}
91 };
92 #endif
93 
95 {
96 public:
98  nostd::string_view /* description */,
99  nostd::string_view /* unit */) noexcept
100  {}
101 
102  void AddCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
103  void RemoveCallback(ObservableCallbackPtr, void * /* state */) noexcept override {}
104 };
105 
109 class NoopMeter final : public Meter
110 {
111 public:
113  nostd::string_view name,
114  nostd::string_view description = "",
115  nostd::string_view unit = "") noexcept override
116  {
117  return nostd::unique_ptr<Counter<uint64_t>>{new NoopCounter<uint64_t>(name, description, unit)};
118  }
119 
121  nostd::string_view name,
122  nostd::string_view description = "",
123  nostd::string_view unit = "") noexcept override
124  {
125  return nostd::unique_ptr<Counter<double>>{new NoopCounter<double>(name, description, unit)};
126  }
127 
129  nostd::string_view name,
130  nostd::string_view description = "",
131  nostd::string_view unit = "") noexcept override
132  {
134  new NoopObservableInstrument(name, description, unit));
135  }
136 
138  nostd::string_view name,
139  nostd::string_view description = "",
140  nostd::string_view unit = "") noexcept override
141  {
143  new NoopObservableInstrument(name, description, unit));
144  }
145 
147  nostd::string_view name,
148  nostd::string_view description = "",
149  nostd::string_view unit = "") noexcept override
150  {
152  new NoopHistogram<uint64_t>(name, description, unit)};
153  }
154 
156  nostd::string_view name,
157  nostd::string_view description = "",
158  nostd::string_view unit = "") noexcept override
159  {
160  return nostd::unique_ptr<Histogram<double>>{new NoopHistogram<double>(name, description, unit)};
161  }
162 
163 #if OPENTELEMETRY_ABI_VERSION_NO >= 2
165  nostd::string_view description = "",
166  nostd::string_view unit = "") noexcept override
167  {
168  return nostd::unique_ptr<Gauge<int64_t>>{new NoopGauge<int64_t>(name, description, unit)};
169  }
170 
171  nostd::unique_ptr<Gauge<double>> CreateDoubleGauge(nostd::string_view name,
172  nostd::string_view description = "",
173  nostd::string_view unit = "") noexcept override
174  {
175  return nostd::unique_ptr<Gauge<double>>{new NoopGauge<double>(name, description, unit)};
176  }
177 #endif
178 
180  nostd::string_view name,
181  nostd::string_view description = "",
182  nostd::string_view unit = "") noexcept override
183  {
185  new NoopObservableInstrument(name, description, unit));
186  }
187 
189  nostd::string_view name,
190  nostd::string_view description = "",
191  nostd::string_view unit = "") noexcept override
192  {
194  new NoopObservableInstrument(name, description, unit));
195  }
196 
198  nostd::string_view name,
199  nostd::string_view description = "",
200  nostd::string_view unit = "") noexcept override
201  {
203  new NoopUpDownCounter<int64_t>(name, description, unit)};
204  }
205 
207  nostd::string_view name,
208  nostd::string_view description = "",
209  nostd::string_view unit = "") noexcept override
210  {
212  new NoopUpDownCounter<double>(name, description, unit)};
213  }
214 
216  nostd::string_view name,
217  nostd::string_view description = "",
218  nostd::string_view unit = "") noexcept override
219  {
221  new NoopObservableInstrument(name, description, unit));
222  }
223 
225  nostd::string_view name,
226  nostd::string_view description = "",
227  nostd::string_view unit = "") noexcept override
228  {
230  new NoopObservableInstrument(name, description, unit));
231  }
232 };
233 
237 class NoopMeterProvider final : public MeterProvider
238 {
239 public:
241 
242 #if OPENTELEMETRY_ABI_VERSION_NO >= 2
244  nostd::string_view /* name */,
245  nostd::string_view /* version */,
246  nostd::string_view /* schema_url */,
247  const common::KeyValueIterable * /* attributes */) noexcept override
248  {
249  return meter_;
250  }
251 #else
253  nostd::string_view /* version */,
254  nostd::string_view /* schema_url */) noexcept override
255  {
256  return meter_;
257  }
258 #endif
259 
260 #if OPENTELEMETRY_ABI_VERSION_NO >= 2
261  void RemoveMeter(nostd::string_view /* name */,
262  nostd::string_view /* version */,
263  nostd::string_view /* schema_url */) noexcept override
264  {}
265 #endif
266 
267 private:
269 };
270 } // namespace metrics
metrics::NoopCounter::Add
void Add(T, const common::KeyValueIterable &, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:28
metrics::Histogram
A histogram instrument that records values.
Definition: includes/opentelemetry/metrics/meter.h:19
metrics::NoopMeter::CreateUInt64Histogram
nostd::unique_ptr< Histogram< uint64_t > > CreateUInt64Histogram(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:146
metrics::NoopUpDownCounter::Add
void Add(T, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:66
nostd::unique_ptr
Provide a simplified port of std::unique_ptr that has ABI stability.
Definition: includes/opentelemetry/nostd/unique_ptr.h:45
nostd::shared_ptr
Provide a type-erased version of std::shared_ptr that has ABI stability.
Definition: includes/opentelemetry/nostd/shared_ptr.h:28
metrics::NoopMeterProvider::GetMeter
nostd::shared_ptr< Meter > GetMeter(nostd::string_view, nostd::string_view, nostd::string_view) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:252
metrics::NoopMeterProvider
No-op implementation of a MeterProvider.
Definition: includes/opentelemetry/metrics/noop.h:237
metrics::NoopObservableInstrument::RemoveCallback
void RemoveCallback(ObservableCallbackPtr, void *) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:103
metrics::NoopObservableInstrument::NoopObservableInstrument
NoopObservableInstrument(nostd::string_view, nostd::string_view, nostd::string_view) noexcept
Definition: includes/opentelemetry/metrics/noop.h:97
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
metrics::NoopMeter::CreateDoubleObservableCounter
nostd::shared_ptr< ObservableInstrument > CreateDoubleObservableCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:137
metrics::ObservableCallbackPtr
void(*)(ObserverResult, void *) ObservableCallbackPtr
Definition: includes/opentelemetry/metrics/async_instruments.h:13
metrics::NoopMeter::CreateDoubleHistogram
nostd::unique_ptr< Histogram< double > > CreateDoubleHistogram(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:155
metrics::Counter
Definition: includes/opentelemetry/metrics/meter.h:16
metrics::NoopHistogram::Record
void Record(T, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:42
metrics::NoopObservableInstrument
Definition: includes/opentelemetry/metrics/noop.h:94
metrics::NoopMeter::CreateInt64ObservableUpDownCounter
nostd::shared_ptr< ObservableInstrument > CreateInt64ObservableUpDownCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:215
metrics::NoopUpDownCounter::Add
void Add(T, const common::KeyValueIterable &, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:68
metrics::NoopUpDownCounter::Add
void Add(T) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:65
metrics::NoopCounter::NoopCounter
NoopCounter(nostd::string_view, nostd::string_view, nostd::string_view) noexcept
Definition: includes/opentelemetry/metrics/noop.h:21
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
metrics::NoopMeter
No-op implementation of Meter.
Definition: includes/opentelemetry/metrics/noop.h:109
metrics::NoopMeter::CreateDoubleCounter
nostd::unique_ptr< Counter< double > > CreateDoubleCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:120
metrics::NoopObservableInstrument::AddCallback
void AddCallback(ObservableCallbackPtr, void *) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:102
metrics::NoopCounter::Add
void Add(T) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:25
common::KeyValueIterable
Supports internal iteration over a collection of key-value pairs.
Definition: includes/opentelemetry/common/key_value_iterable.h:17
metrics::NoopMeter::CreateDoubleObservableGauge
nostd::shared_ptr< ObservableInstrument > CreateDoubleObservableGauge(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:188
metrics::NoopMeter::CreateInt64ObservableCounter
nostd::shared_ptr< ObservableInstrument > CreateInt64ObservableCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:128
metrics::NoopCounter
Definition: includes/opentelemetry/metrics/noop.h:18
metrics::NoopCounter::Add
void Add(T, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:26
metrics::NoopUpDownCounter::~NoopUpDownCounter
~NoopUpDownCounter() override=default
metrics::NoopUpDownCounter::Add
void Add(T, const common::KeyValueIterable &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:67
metrics::NoopCounter::Add
void Add(T, const common::KeyValueIterable &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:27
metrics::NoopUpDownCounter
Definition: includes/opentelemetry/metrics/noop.h:57
metrics::NoopMeter::CreateDoubleUpDownCounter
nostd::unique_ptr< UpDownCounter< double > > CreateDoubleUpDownCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:206
metrics::NoopUpDownCounter::NoopUpDownCounter
NoopUpDownCounter(nostd::string_view, nostd::string_view, nostd::string_view) noexcept
Definition: includes/opentelemetry/metrics/noop.h:60
metrics::NoopMeterProvider::NoopMeterProvider
NoopMeterProvider()
Definition: includes/opentelemetry/metrics/noop.h:240
metrics::NoopMeter::CreateDoubleObservableUpDownCounter
nostd::shared_ptr< ObservableInstrument > CreateDoubleObservableUpDownCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:224
metrics::UpDownCounter
An up-down-counter instrument that adds or reduce values.
Definition: includes/opentelemetry/metrics/meter.h:22
context::Context
Definition: includes/opentelemetry/context/context.h:23
metrics::ObservableInstrument
Definition: includes/opentelemetry/metrics/async_instruments.h:15
metrics
Definition: includes/opentelemetry/metrics/async_instruments.h:10
metrics::NoopHistogram
Definition: includes/opentelemetry/metrics/noop.h:35
metrics::NoopMeter::CreateUInt64Counter
nostd::unique_ptr< Counter< uint64_t > > CreateUInt64Counter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:112
metrics::NoopHistogram::NoopHistogram
NoopHistogram(nostd::string_view, nostd::string_view, nostd::string_view) noexcept
Definition: includes/opentelemetry/metrics/noop.h:38
metrics::Meter
Handles instrument creation and provides a facility for batch recording.
Definition: includes/opentelemetry/metrics/meter.h:37
metrics::MeterProvider
Creates new Meter instances.
Definition: includes/opentelemetry/metrics/meter_provider.h:22
metrics::NoopMeter::CreateInt64ObservableGauge
nostd::shared_ptr< ObservableInstrument > CreateInt64ObservableGauge(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:179
metrics::NoopHistogram::Record
void Record(T, const common::KeyValueIterable &, const context::Context &) noexcept override
Definition: includes/opentelemetry/metrics/noop.h:43
metrics::NoopMeter::CreateInt64UpDownCounter
nostd::unique_ptr< UpDownCounter< int64_t > > CreateInt64UpDownCounter(nostd::string_view name, nostd::string_view description="", nostd::string_view unit="") noexcept override
Definition: includes/opentelemetry/metrics/noop.h:197
nostd::string_view
Back port of std::string_view to work with pre-cpp-17 compilers.
Definition: includes/opentelemetry/nostd/string_view.h:37