Logger System 0.1.3
High-performance C++20 thread-safe logging system with asynchronous capabilities
Loading...
Searching...
No Matches
kcenon::logger::otlp::otel_context Struct Reference

OpenTelemetry context for trace correlation. More...

#include <otel_context.h>

Collaboration diagram for kcenon::logger::otlp::otel_context:
Collaboration graph

Public Member Functions

bool is_valid () const noexcept
 Check if context is valid.
 
bool is_sampled () const noexcept
 Check if trace is sampled.
 

Static Public Member Functions

static otel_context empty () noexcept
 Create an empty/invalid context.
 

Public Attributes

std::string trace_id
 
std::string span_id
 
std::string trace_flags
 
std::string trace_state
 

Static Private Member Functions

static bool is_valid_hex (const std::string &str) noexcept
 

Detailed Description

OpenTelemetry context for trace correlation.

Contains trace identification and propagation information following the W3C Trace Context specification.

Definition at line 45 of file otel_context.h.

Member Function Documentation

◆ empty()

static otel_context kcenon::logger::otlp::otel_context::empty ( )
inlinestaticnodiscardnoexcept

Create an empty/invalid context.

Returns
Empty otel_context
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/otlp/otel_context.h.

Definition at line 120 of file otel_context.h.

120 {
121 return otel_context{};
122 }

◆ is_sampled()

bool kcenon::logger::otlp::otel_context::is_sampled ( ) const
inlinenodiscardnoexcept

Check if trace is sampled.

Returns
true if the sampled flag (bit 0) is set
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/otlp/otel_context.h.

Definition at line 103 of file otel_context.h.

103 {
104 if (trace_flags.empty()) {
105 return false;
106 }
107 // Check if the last character is '1', '3', '5', '7', '9', 'b', 'd', 'f'
108 // (odd numbers in hex, meaning bit 0 is set)
109 char last = trace_flags.back();
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');
113 }

References trace_flags.

◆ is_valid()

bool kcenon::logger::otlp::otel_context::is_valid ( ) const
inlinenodiscardnoexcept

Check if context is valid.

Returns
true if trace_id and span_id are present and properly formatted
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/otlp/otel_context.h.

Definition at line 93 of file otel_context.h.

93 {
94 return trace_id.length() == 32 && span_id.length() == 16 &&
96 }
static bool is_valid_hex(const std::string &str) noexcept

References is_valid_hex(), span_id, and trace_id.

Here is the call graph for this function:

◆ is_valid_hex()

static bool kcenon::logger::otlp::otel_context::is_valid_hex ( const std::string & str)
inlinestaticnodiscardprivatenoexcept
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/otlp/otel_context.h.

Definition at line 125 of file otel_context.h.

125 {
126 for (char c : str) {
127 if (!((c >= '0' && c <= '9') ||
128 (c >= 'a' && c <= 'f') ||
129 (c >= 'A' && c <= 'F'))) {
130 return false;
131 }
132 }
133 return true;
134 }

Referenced by is_valid().

Here is the caller graph for this function:

Member Data Documentation

◆ span_id

◆ trace_flags

◆ trace_id

◆ trace_state


The documentation for this struct was generated from the following file: