]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/_metrics/async_instruments.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / _metrics / async_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 # include "opentelemetry/_metrics/observer_result.h"
9
10 OPENTELEMETRY_BEGIN_NAMESPACE
11 namespace metrics
12 {
13
14 template <class T>
15 class ValueObserver : virtual public AsynchronousInstrument<T>
16 {
17
18 public:
19 ValueObserver() = default;
20
21 ValueObserver(nostd::string_view name,
22 nostd::string_view description,
23 nostd::string_view unit,
24 bool enabled,
25 void (*callback)(ObserverResult<T>))
26 {}
27
28 /*
29 * Updates the instruments aggregator with the new value. The labels should
30 * contain the keys and values to be associated with this value.
31 *
32 * @param value is the numerical representation of the metric being captured
33 * @param labels the set of labels, as key-value pairs
34 */
35 virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
36
37 /**
38 * Captures data by activating the callback function associated with the
39 * instrument and storing its return value. Callbacks for asynchronous
40 * instruments are defined during construction.
41 *
42 * @param none
43 * @return none
44 */
45 virtual void run() override = 0;
46 };
47
48 template <class T>
49 class SumObserver : virtual public AsynchronousInstrument<T>
50 {
51
52 public:
53 SumObserver() = default;
54
55 SumObserver(nostd::string_view name,
56 nostd::string_view description,
57 nostd::string_view unit,
58 bool enabled,
59 void (*callback)(ObserverResult<T>))
60 {}
61
62 virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
63
64 virtual void run() override = 0;
65 };
66
67 template <class T>
68 class UpDownSumObserver : virtual public AsynchronousInstrument<T>
69 {
70
71 public:
72 UpDownSumObserver() = default;
73
74 UpDownSumObserver(nostd::string_view name,
75 nostd::string_view description,
76 nostd::string_view unit,
77 bool enabled,
78 void (*callback)(ObserverResult<T>))
79 {}
80
81 virtual void observe(T value, const common::KeyValueIterable &labels) override = 0;
82
83 virtual void run() override = 0;
84 };
85
86 } // namespace metrics
87 OPENTELEMETRY_END_NAMESPACE
88 #endif