]> git.proxmox.com Git - ceph.git/blob - ceph/src/jaegertracing/opentelemetry-cpp/api/include/opentelemetry/trace/context.h
update ceph source to reef 18.1.2
[ceph.git] / ceph / src / jaegertracing / opentelemetry-cpp / api / include / opentelemetry / trace / context.h
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 #pragma once
5
6 #include "opentelemetry/context/context.h"
7 #include "opentelemetry/trace/default_span.h"
8 #include "opentelemetry/version.h"
9
10 OPENTELEMETRY_BEGIN_NAMESPACE
11 namespace trace
12 {
13
14 // Get Span from explicit context
15 inline nostd::shared_ptr<Span> GetSpan(const opentelemetry::context::Context &context) noexcept
16 {
17 context::ContextValue span = context.GetValue(kSpanKey);
18 if (nostd::holds_alternative<nostd::shared_ptr<Span>>(span))
19 {
20 return nostd::get<nostd::shared_ptr<Span>>(span);
21 }
22 return nostd::shared_ptr<Span>(new DefaultSpan(SpanContext::GetInvalid()));
23 }
24
25 // Set Span into explicit context
26 inline context::Context SetSpan(opentelemetry::context::Context &context,
27 nostd::shared_ptr<Span> span) noexcept
28 {
29 return context.SetValue(kSpanKey, span);
30 }
31
32 } // namespace trace
33 OPENTELEMETRY_END_NAMESPACE