Monitoring System 0.1.0
System resource monitoring with pluggable collectors and alerting
Loading...
Searching...
No Matches
kcenon::monitoring::thread_context_data Struct Reference

Enhanced thread context data for comprehensive request and trace tracking. More...

#include <thread_context.h>

Collaboration diagram for kcenon::monitoring::thread_context_data:
Collaboration graph

Public Member Functions

 thread_context_data ()
 Default constructor. Records the current time as start_time.
 
 thread_context_data (std::string req_id)
 Construct with a request ID. Records the current time as start_time.
 
void add_tag (const std::string &key, const std::string &value)
 Add or update a custom tag.
 
std::string get_tag (const std::string &key) const
 Retrieve a tag value by key.
 

Public Attributes

std::string request_id
 Unique identifier for the current request.
 
std::string correlation_id
 Correlation ID for cross-service tracing.
 
std::string user_id
 User identifier associated with the request.
 
std::string span_id
 Current span ID for distributed tracing.
 
std::string trace_id
 Trace ID linking all spans in a trace.
 
std::chrono::steady_clock::time_point start_time
 Context creation timestamp.
 
std::optional< std::string > parent_span_id
 Parent span ID (if nested)
 
std::unordered_map< std::string, std::string > tags
 Arbitrary key-value tags.
 

Detailed Description

Enhanced thread context data for comprehensive request and trace tracking.

Extends basic context metadata with distributed tracing fields (span_id, trace_id, parent_span_id) and timing information. Each instance records its creation time for elapsed duration calculations.

See also
thread_context For managing thread-local instances of this struct

Definition at line 107 of file thread_context.h.

Constructor & Destructor Documentation

◆ thread_context_data() [1/2]

kcenon::monitoring::thread_context_data::thread_context_data ( )
inline

Default constructor. Records the current time as start_time.

Definition at line 120 of file thread_context.h.

120: start_time(std::chrono::steady_clock::now()) {}
std::chrono::steady_clock::time_point start_time
Context creation timestamp.

◆ thread_context_data() [2/2]

kcenon::monitoring::thread_context_data::thread_context_data ( std::string req_id)
inlineexplicit

Construct with a request ID. Records the current time as start_time.

Parameters
req_idRequest identifier

Definition at line 126 of file thread_context.h.

127 : request_id(std::move(req_id))
128 , start_time(std::chrono::steady_clock::now()) {}
std::string request_id
Unique identifier for the current request.

Member Function Documentation

◆ add_tag()

void kcenon::monitoring::thread_context_data::add_tag ( const std::string & key,
const std::string & value )
inline

Add or update a custom tag.

Parameters
keyTag name
valueTag value

Definition at line 135 of file thread_context.h.

135 {
136 tags[key] = value;
137 }
std::unordered_map< std::string, std::string > tags
Arbitrary key-value tags.

References tags.

Referenced by TEST_F(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

◆ get_tag()

std::string kcenon::monitoring::thread_context_data::get_tag ( const std::string & key) const
inline

Retrieve a tag value by key.

Parameters
keyTag name to look up
Returns
The tag value, or empty string if not found

Definition at line 144 of file thread_context.h.

144 {
145 auto it = tags.find(key);
146 return it != tags.end() ? it->second : "";
147 }

References tags.

Referenced by TEST_F(), TEST_F(), and TEST_F().

Here is the caller graph for this function:

Member Data Documentation

◆ correlation_id

std::string kcenon::monitoring::thread_context_data::correlation_id

Correlation ID for cross-service tracing.

Definition at line 109 of file thread_context.h.

Referenced by TEST(), TEST_F(), and TEST_F().

◆ parent_span_id

std::optional<std::string> kcenon::monitoring::thread_context_data::parent_span_id

Parent span ID (if nested)

Definition at line 114 of file thread_context.h.

Referenced by TEST().

◆ request_id

std::string kcenon::monitoring::thread_context_data::request_id

Unique identifier for the current request.

Definition at line 108 of file thread_context.h.

Referenced by TEST().

◆ span_id

std::string kcenon::monitoring::thread_context_data::span_id

Current span ID for distributed tracing.

Definition at line 111 of file thread_context.h.

Referenced by TEST().

◆ start_time

std::chrono::steady_clock::time_point kcenon::monitoring::thread_context_data::start_time

Context creation timestamp.

Definition at line 113 of file thread_context.h.

◆ tags

std::unordered_map<std::string, std::string> kcenon::monitoring::thread_context_data::tags

Arbitrary key-value tags.

Definition at line 115 of file thread_context.h.

Referenced by add_tag(), get_tag(), and TEST().

◆ trace_id

std::string kcenon::monitoring::thread_context_data::trace_id

Trace ID linking all spans in a trace.

Definition at line 112 of file thread_context.h.

Referenced by TEST().

◆ user_id

std::string kcenon::monitoring::thread_context_data::user_id

User identifier associated with the request.

Definition at line 110 of file thread_context.h.

Referenced by TEST(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), TEST_F(), and TEST_F().


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