NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/metrics/observer_result.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/common/attribute_value.h"
7 #include "opentelemetry/common/key_value_iterable_view.h"
8 #include "opentelemetry/nostd/shared_ptr.h"
9 #include "opentelemetry/nostd/span.h"
10 #include "opentelemetry/nostd/string_view.h"
11 #include "opentelemetry/nostd/type_traits.h"
12 #include "opentelemetry/nostd/variant.h"
13 #include "opentelemetry/version.h"
14 
16 namespace metrics
17 {
18 
23 template <class T>
25 {
26 
27 public:
28  virtual ~ObserverResultT() = default;
29 
30  virtual void Observe(T value) noexcept = 0;
31 
32  virtual void Observe(T value, const common::KeyValueIterable &attributes) noexcept = 0;
33 
34  template <class U,
36  void Observe(T value, const U &attributes) noexcept
37  {
38  this->Observe(value, common::KeyValueIterableView<U>{attributes});
39  }
40 
41  void Observe(T value,
42  std::initializer_list<std::pair<nostd::string_view, common::AttributeValue>>
43  attributes) noexcept
44  {
45  this->Observe(value, nostd::span<const std::pair<nostd::string_view, common::AttributeValue>>{
46  attributes.begin(), attributes.end()});
47  }
48 };
49 
52 
53 } // namespace metrics
absl::OTABSL_OPTION_NAMESPACE_NAME::variant
Definition: includes/opentelemetry/nostd/variant.h:61
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::ObserverResultT
ObserverResultT class is necessary for the callback recording asynchronous instrument use.
Definition: includes/opentelemetry/metrics/observer_result.h:24
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
nostd::span
Back port of std::span.
Definition: includes/opentelemetry/nostd/span.h:51
metrics::ObserverResultT::~ObserverResultT
virtual ~ObserverResultT()=default
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
common::KeyValueIterable
Supports internal iteration over a collection of key-value pairs.
Definition: includes/opentelemetry/common/key_value_iterable.h:17
nostd::enable_if_t
typename std::enable_if< B, T >::type enable_if_t
Back port of std::enable_if_t.
Definition: includes/opentelemetry/nostd/type_traits.h:40
common::KeyValueIterableView
Container for key-value pairs that can transform every value in it to one of types listed in common::...
Definition: includes/opentelemetry/common/key_value_iterable_view.h:57
metrics::ObserverResult
nostd::variant< nostd::shared_ptr< ObserverResultT< int64_t > >, nostd::shared_ptr< ObserverResultT< double > >> ObserverResult
Definition: includes/opentelemetry/metrics/observer_result.h:51
metrics::ObserverResultT::Observe
void Observe(T value, std::initializer_list< std::pair< nostd::string_view, common::AttributeValue >> attributes) noexcept
Definition: includes/opentelemetry/metrics/observer_result.h:41
metrics
Definition: includes/opentelemetry/metrics/async_instruments.h:10
metrics::ObserverResultT::Observe
virtual void Observe(T value) noexcept=0
metrics::ObserverResultT::Observe
void Observe(T value, const U &attributes) noexcept
Definition: includes/opentelemetry/metrics/observer_result.h:36