22#include <unordered_map>
110 return (last ==
'1' || last ==
'3' || last ==
'5' || last ==
'7' ||
111 last ==
'9' || last ==
'b' || last ==
'd' || last ==
'f' ||
112 last ==
'B' || last ==
'D' || last ==
'F');
125 [[nodiscard]]
static bool is_valid_hex(
const std::string& str)
noexcept {
127 if (!((c >=
'0' && c <=
'9') ||
128 (c >=
'a' && c <=
'f') ||
129 (c >=
'A' && c <=
'F'))) {
232 [[nodiscard]]
static std::optional<otel_context>
get() {
263 thread_local bool has_ctx =
false;
RAII guard for OpenTelemetry context.
otel_context_scope(otel_context_scope &&)=delete
otel_context_scope(const otel_context &ctx)
Construct and set context.
~otel_context_scope()
Destructor - restores previous context.
otel_context_scope & operator=(otel_context_scope &&)=delete
otel_context_scope(const otel_context_scope &)=delete
otel_context_scope & operator=(const otel_context_scope &)=delete
std::optional< otel_context > previous_context_
Thread-local storage for OpenTelemetry context.
static bool & get_has_context()
static otel_context & get_storage()
static bool has_context()
Check if a context is set for the current thread.
static std::optional< otel_context > get()
Get the OpenTelemetry context for the current thread.
static void set(const otel_context &ctx)
Set the OpenTelemetry context for the current thread.
static void clear()
Clear the OpenTelemetry context for the current thread.
OpenTelemetry context for trace correlation.
bool is_sampled() const noexcept
Check if trace is sampled.
static otel_context empty() noexcept
Create an empty/invalid context.
static bool is_valid_hex(const std::string &str) noexcept
bool is_valid() const noexcept
Check if context is valid.
OpenTelemetry resource attributes.
std::string service_instance_id
std::string service_version
std::string service_namespace
std::unordered_map< std::string, std::string > attributes