]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/_metrics/sync_instruments.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / _metrics / sync_instruments.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5 #ifdef ENABLE_METRICS_PREVIEW
6
7 # include "opentelemetry/_metrics/instrument.h"
8
9 OPENTELEMETRY_BEGIN_NAMESPACE
10 namespace metrics
11 {
12
13 template <class T>
14 class BoundCounter : virtual public BoundSynchronousInstrument<T>
15 {
16
17 public:
18 BoundCounter() = default;
19
20 BoundCounter(nostd::string_view name,
21 nostd::string_view description,
22 nostd::string_view unit,
23 bool enabled);
24
25 /*
26 * Add adds the value to the counter's sum. The labels are already linked * to the instrument
27 * and are not specified.
28 *
29 * @param value the numerical representation of the metric being captured
30 * @param labels the set of labels, as key-value pairs
31 */
32 virtual void add(T value) = 0;
33 };
34
35 template <class T>
36 class Counter : virtual public SynchronousInstrument<T>
37 {
38
39 public:
40 Counter() = default;
41
42 Counter(nostd::string_view name,
43 nostd::string_view description,
44 nostd::string_view unit,
45 bool enabled)
46 {}
47
48 /*
49 * Bind creates a bound instrument for this counter. The labels are
50 * associated with values recorded via subsequent calls to Record.
51 *
52 * @param labels the set of labels, as key-value pairs.
53 * @return a BoundIntCounter tied to the specified labels
54 */
55 virtual nostd::shared_ptr<BoundCounter<T>> bindCounter(const common::KeyValueIterable &labels)
56 {
57 return nostd::shared_ptr<BoundCounter<T>>();
58 }
59
60 /*
61 * Add adds the value to the counter's sum. The labels should contain
62 * the keys and values to be associated with this value. Counters only * accept positive
63 * valued updates.
64 *
65 * @param value the numerical representation of the metric being captured
66 * @param labels the set of labels, as key-value pairs
67 */
68 virtual void add(T value, const common::KeyValueIterable &labels) = 0;
69
70 virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
71 };
72
73 template <class T>
74 class BoundUpDownCounter : virtual public BoundSynchronousInstrument<T>
75 {
76
77 public:
78 BoundUpDownCounter() = default;
79
80 BoundUpDownCounter(nostd::string_view name,
81 nostd::string_view description,
82 nostd::string_view unit,
83 bool enabled);
84
85 /*
86 * Add adds the value to the counter's sum. The labels are already linked to * the instrument and
87 * do not need to specified again. UpDownCounters can accept positive and negative values.
88 *
89 * @param value the numerical representation of the metric being captured
90 * @param labels the set of labels, as key-value pairs
91 */
92 virtual void add(T value) = 0;
93 };
94
95 template <class T>
96 class UpDownCounter : virtual public SynchronousInstrument<T>
97 {
98
99 public:
100 UpDownCounter() = default;
101
102 UpDownCounter(nostd::string_view name,
103 nostd::string_view description,
104 nostd::string_view unit,
105 bool enabled);
106
107 virtual nostd::shared_ptr<BoundUpDownCounter<T>> bindUpDownCounter(
108 const common::KeyValueIterable &labels)
109 {
110 return nostd::shared_ptr<BoundUpDownCounter<T>>();
111 }
112
113 /*
114 * Add adds the value to the counter's sum. The labels should contain
115 * the keys and values to be associated with this value. UpDownCounters can
116 * accept positive and negative values.
117 *
118 * @param value the numerical representation of the metric being captured
119 * @param labels the set of labels, as key-value pairs
120 */
121 virtual void add(T value, const common::KeyValueIterable &labels) = 0;
122
123 virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
124 };
125
126 template <class T>
127 class BoundValueRecorder : virtual public BoundSynchronousInstrument<T>
128 {
129
130 public:
131 BoundValueRecorder() = default;
132
133 BoundValueRecorder(nostd::string_view name,
134 nostd::string_view description,
135 nostd::string_view unit,
136 bool enabled);
137
138 /*
139 * Records the value by summing it with previous measurements and checking * previously stored
140 * minimum and maximum values. The labels associated with * new values are already linked to the
141 * instrument as it is bound. * ValueRecorders can accept positive and negative values.
142 *
143 * @param value the numerical representation of the metric being captured
144 */
145 virtual void record(T value) = 0;
146 };
147
148 template <class T>
149 class ValueRecorder : virtual public SynchronousInstrument<T>
150 {
151
152 public:
153 ValueRecorder() = default;
154
155 ValueRecorder(nostd::string_view name,
156 nostd::string_view description,
157 nostd::string_view unit,
158 bool enabled);
159
160 virtual nostd::shared_ptr<BoundValueRecorder<T>> bindValueRecorder(
161 const common::KeyValueIterable &labels)
162 {
163 return nostd::shared_ptr<BoundValueRecorder<T>>();
164 }
165
166 /*
167 * Records the value by summing it with previous measurements and checking * previously stored
168 * minimum and maximum values. The labels should contain the keys and values to be associated with
169 * this value. ValueRecorders can accept positive and negative values.
170 *
171 * @param value the numerical representation of the metric being captured
172 * @param labels the set of labels, as key-value pairs
173 */
174 virtual void record(T value, const common::KeyValueIterable &labels) = 0;
175
176 virtual void update(T value, const common::KeyValueIterable &labels) override = 0;
177 };
178
179 } // namespace metrics
180 OPENTELEMETRY_END_NAMESPACE
181 #endif