]> git.proxmox.com Git - ceph.git/blobdiff - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/context/propagation/global_propagator.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / context / propagation / global_propagator.h
diff --git a/ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/context/propagation/global_propagator.h b/ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/context/propagation/global_propagator.h
new file mode 100644 (file)
index 0000000..b4e4932
--- /dev/null
@@ -0,0 +1,55 @@
+// Copyright The OpenTelemetry Authors
+// SPDX-License-Identifier: Apache-2.0
+
+#pragma once
+
+#include <mutex>
+
+#include "opentelemetry/context/propagation/noop_propagator.h"
+#include "opentelemetry/context/propagation/text_map_propagator.h"
+
+#include "opentelemetry/common/spin_lock_mutex.h"
+#include "opentelemetry/nostd/shared_ptr.h"
+
+#include "opentelemetry/version.h"
+
+OPENTELEMETRY_BEGIN_NAMESPACE
+namespace context
+{
+namespace propagation
+{
+
+/* Stores the singleton TextMapPropagator */
+
+class GlobalTextMapPropagator
+{
+public:
+  static nostd::shared_ptr<TextMapPropagator> GetGlobalPropagator() noexcept
+  {
+    std::lock_guard<common::SpinLockMutex> guard(GetLock());
+    return nostd::shared_ptr<TextMapPropagator>(GetPropagator());
+  }
+
+  static void SetGlobalPropagator(nostd::shared_ptr<TextMapPropagator> prop) noexcept
+  {
+    std::lock_guard<common::SpinLockMutex> guard(GetLock());
+    GetPropagator() = prop;
+  }
+
+private:
+  static nostd::shared_ptr<TextMapPropagator> &GetPropagator() noexcept
+  {
+    static nostd::shared_ptr<TextMapPropagator> propagator(new NoOpPropagator());
+    return propagator;
+  }
+
+  static common::SpinLockMutex &GetLock() noexcept
+  {
+    static common::SpinLockMutex lock;
+    return lock;
+  }
+};
+
+}  // namespace propagation
+}  // namespace context
+OPENTELEMETRY_END_NAMESPACE
\ No newline at end of file