NVIDIA DeepStream SDK API Reference

9.2 Release
includes/opentelemetry/context/propagation/global_propagator.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 <mutex>
7 
8 #include "opentelemetry/context/propagation/noop_propagator.h"
9 
10 #include "opentelemetry/common/macros.h"
11 #include "opentelemetry/common/spin_lock_mutex.h"
12 #include "opentelemetry/nostd/shared_ptr.h"
13 
14 #include "opentelemetry/version.h"
15 
17 namespace context
18 {
19 namespace propagation
20 {
21 
22 class TextMapPropagator;
23 
24 /* Stores the singleton TextMapPropagator */
25 
27 {
28 public:
30  {
31  std::lock_guard<common::SpinLockMutex> guard(GetLock());
32  return nostd::shared_ptr<TextMapPropagator>(GetPropagator());
33  }
34 
36  {
37  std::lock_guard<common::SpinLockMutex> guard(GetLock());
38  GetPropagator() = prop;
39  }
40 
41 private:
43  {
45  return propagator;
46  }
47 
48  OPENTELEMETRY_API_SINGLETON static common::SpinLockMutex &GetLock() noexcept
49  {
50  static common::SpinLockMutex lock;
51  return lock;
52  }
53 };
54 
55 } // namespace propagation
56 } // namespace context
OPENTELEMETRY_EXPORT
#define OPENTELEMETRY_EXPORT
Definition: includes/opentelemetry/common/macros.h:386
nostd::shared_ptr
Provide a type-erased version of std::shared_ptr that has ABI stability.
Definition: includes/opentelemetry/nostd/shared_ptr.h:28
OPENTELEMETRY_BEGIN_NAMESPACE
#define OPENTELEMETRY_BEGIN_NAMESPACE
Definition: includes/opentelemetry/version.h:21
common::SpinLockMutex
A Mutex which uses atomic flags and spin-locks instead of halting threads.
Definition: includes/opentelemetry/common/spin_lock_mutex.h:52
context
Definition: includes/opentelemetry/context/context.h:16
context::propagation::GlobalTextMapPropagator::GetGlobalPropagator
static nostd::shared_ptr< TextMapPropagator > GetGlobalPropagator() noexcept
Definition: includes/opentelemetry/context/propagation/global_propagator.h:29
context::propagation::GlobalTextMapPropagator::SetGlobalPropagator
static void SetGlobalPropagator(const nostd::shared_ptr< TextMapPropagator > &prop) noexcept
Definition: includes/opentelemetry/context/propagation/global_propagator.h:35
OPENTELEMETRY_END_NAMESPACE
#define OPENTELEMETRY_END_NAMESPACE
Definition: includes/opentelemetry/version.h:24
OPENTELEMETRY_API_SINGLETON
#define OPENTELEMETRY_API_SINGLETON
Definition: includes/opentelemetry/common/macros.h:335
context::propagation::GlobalTextMapPropagator
Definition: includes/opentelemetry/context/propagation/global_propagator.h:26
context::propagation::NoOpPropagator
No-op implementation TextMapPropagator.
Definition: includes/opentelemetry/context/propagation/noop_propagator.h:18