.. _program_listing_file_include_opentelemetry_trace_propagation_detail_context.h: Program Listing for File context.h ================================== |exhale_lsh| :ref:`Return to documentation for file ` (``include/opentelemetry/trace/propagation/detail/context.h``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp #pragma once #include "opentelemetry/context/context.h" #include "opentelemetry/trace/default_span.h" OPENTELEMETRY_BEGIN_NAMESPACE namespace trace { namespace propagation { inline nostd::shared_ptr GetSpan(const context::Context &context) { context::ContextValue span = context.GetValue(trace::kSpanKey); if (nostd::holds_alternative>(span)) { return nostd::get>(span); } return nostd::shared_ptr(new DefaultSpan(SpanContext::GetInvalid())); } inline context::Context SetSpan(context::Context &context, nostd::shared_ptr span) { return context.SetValue(kSpanKey, span); } } // namespace propagation } // namespace trace OPENTELEMETRY_END_NAMESPACE