]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/_metrics/observer_result.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / _metrics / observer_result.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/nostd/shared_ptr.h"
9
10 OPENTELEMETRY_BEGIN_NAMESPACE
11 namespace metrics
12 {
13
14 /**
15 * ObserverResult class is necessary for the callback recording asynchronous
16 * instrument use. Callback functions asynchronous instruments are designed to
17 * accept a single ObserverResult object and update using its pointer to the
18 * instrument itself.
19 */
20
21 template <class T>
22 class ObserverResult
23 {
24
25 public:
26 ObserverResult() = default;
27
28 ObserverResult(AsynchronousInstrument<T> *instrument) : instrument_(instrument) {}
29
30 virtual void observe(T value, const common::KeyValueIterable &labels)
31 {
32 instrument_->observe(value, labels);
33 }
34
35 private:
36 AsynchronousInstrument<T> *instrument_;
37 };
38
39 } // namespace metrics
40 OPENTELEMETRY_END_NAMESPACE
41 #endif