| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 | // Copyright The OpenTelemetry Authors// SPDX-License-Identifier: Apache-2.0#pragma once#include "opentelemetry/context/context.h"#include "opentelemetry/nostd/shared_ptr.h"#include "opentelemetry/trace/default_span.h"#include "opentelemetry/version.h"OPENTELEMETRY_BEGIN_NAMESPACEnamespace trace{// Get Span from explicit contextinline nostd::shared_ptr<Span> GetSpan(const context::Context &context) noexcept{  context::ContextValue span = context.GetValue(kSpanKey);  if (nostd::holds_alternative<nostd::shared_ptr<Span>>(span))  {    return nostd::get<nostd::shared_ptr<Span>>(span);  }  return nostd::shared_ptr<Span>(new DefaultSpan(SpanContext::GetInvalid()));}inline bool IsRootSpan(const context::Context &context) noexcept{  context::ContextValue is_root_span = context.GetValue(kIsRootSpanKey);  if (nostd::holds_alternative<bool>(is_root_span))  {    return nostd::get<bool>(is_root_span);  }  return false;}// Set Span into explicit contextinline context::Context SetSpan(context::Context &context,                                const nostd::shared_ptr<Span> &span) noexcept{  return context.SetValue(kSpanKey, span);}}  // namespace traceOPENTELEMETRY_END_NAMESPACE
 |