Class RuntimeContext

Class Documentation

class RuntimeContext

Public Static Functions

static inline Context GetCurrent() noexcept
static inline nostd::unique_ptr<Token> Attach(const Context &context) noexcept
static inline bool Detach(Token &token) noexcept
static inline Context SetValue(nostd::string_view key, const ContextValue &value, Context *context = nullptr) noexcept
static inline ContextValue GetValue(nostd::string_view key, Context *context = nullptr) noexcept
static inline void SetRuntimeContextStorage(nostd::shared_ptr<RuntimeContextStorage> storage) noexcept

Provide a custom runtime context storage.

This provides a possibility to override the default thread-local runtime context storage. This has to be set before any spans are created by the application, otherwise the behavior is undefined.

Parameters

storage – a custom runtime context storage

static inline nostd::shared_ptr<const RuntimeContextStorage> GetConstRuntimeContextStorage() noexcept

Provide a pointer to const runtime context storage.

The returned pointer can only be used for extending the lifetime of the runtime context storage.