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_scope Class Reference

RAII guard for OpenTelemetry context. More...

#include <otel_context.h>

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

Public Member Functions

 otel_context_scope (const otel_context &ctx)
 Construct and set context.
 
 ~otel_context_scope ()
 Destructor - restores previous context.
 
 otel_context_scope (const otel_context_scope &)=delete
 
otel_context_scopeoperator= (const otel_context_scope &)=delete
 
 otel_context_scope (otel_context_scope &&)=delete
 
otel_context_scopeoperator= (otel_context_scope &&)=delete
 

Private Attributes

std::optional< otel_contextprevious_context_
 
bool had_previous_
 

Detailed Description

RAII guard for OpenTelemetry context.

Automatically sets context on construction and clears it on destruction. Useful for request processing.

Definition at line 286 of file otel_context.h.

Constructor & Destructor Documentation

◆ otel_context_scope() [1/3]

kcenon::logger::otlp::otel_context_scope::otel_context_scope ( const otel_context & ctx)
inlineexplicit

Construct and set context.

Parameters
ctxContext to set for this scope
Examples
/home/runner/work/logger_system/logger_system/include/kcenon/logger/otlp/otel_context.h.

Definition at line 293 of file otel_context.h.

297 }
std::optional< otel_context > previous_context_
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.

References kcenon::logger::otlp::otel_context_storage::set().

Here is the call graph for this function:

◆ ~otel_context_scope()

kcenon::logger::otlp::otel_context_scope::~otel_context_scope ( )
inline

Destructor - restores previous context.

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

Definition at line 302 of file otel_context.h.

302 {
303 if (had_previous_) {
305 } else {
307 }
308 }
static void clear()
Clear the OpenTelemetry context for the current thread.

References kcenon::logger::otlp::otel_context_storage::clear(), had_previous_, previous_context_, and kcenon::logger::otlp::otel_context_storage::set().

Here is the call graph for this function:

◆ otel_context_scope() [2/3]

kcenon::logger::otlp::otel_context_scope::otel_context_scope ( const otel_context_scope & )
delete

◆ otel_context_scope() [3/3]

kcenon::logger::otlp::otel_context_scope::otel_context_scope ( otel_context_scope && )
delete

Member Function Documentation

◆ operator=() [1/2]

otel_context_scope & kcenon::logger::otlp::otel_context_scope::operator= ( const otel_context_scope & )
delete

◆ operator=() [2/2]

otel_context_scope & kcenon::logger::otlp::otel_context_scope::operator= ( otel_context_scope && )
delete

Member Data Documentation

◆ had_previous_

bool kcenon::logger::otlp::otel_context_scope::had_previous_
private

◆ previous_context_

std::optional<otel_context> kcenon::logger::otlp::otel_context_scope::previous_context_
private

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