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

Context metadata for thread-specific information. More...

#include <thread_context.h>

Collaboration diagram for kcenon::monitoring::context_metadata:
Collaboration graph

Public Member Functions

 context_metadata (std::string req_id="")
 Construct context metadata with an optional request ID.
 
bool empty () const
 Check if all metadata fields are empty.
 
void set_tag (const std::string &key, const std::string &value)
 Set a custom tag on this context.
 
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 tracing across services.
 
std::string user_id
 User identifier associated with the request.
 
std::unordered_map< std::string, std::string > tags
 Arbitrary key-value tags.
 

Detailed Description

Context metadata for thread-specific information.

Lightweight metadata struct for attaching request-scoped information to the current thread. Useful for correlating log entries and metrics with specific requests.

Definition at line 57 of file thread_context.h.

Constructor & Destructor Documentation

◆ context_metadata()

kcenon::monitoring::context_metadata::context_metadata ( std::string req_id = "")
inlineexplicit

Construct context metadata with an optional request ID.

Parameters
req_idRequest identifier (defaults to empty string)

Definition at line 67 of file thread_context.h.

68 : request_id(std::move(req_id)) {}
std::string request_id
Unique identifier for the current request.

Member Function Documentation

◆ empty()

bool kcenon::monitoring::context_metadata::empty ( ) const
inline

Check if all metadata fields are empty.

Returns
true if no metadata has been set, false otherwise

Definition at line 74 of file thread_context.h.

74 {
75 return request_id.empty() && correlation_id.empty() && user_id.empty() && tags.empty();
76 }
std::string correlation_id
Correlation ID for tracing across services.
std::unordered_map< std::string, std::string > tags
Arbitrary key-value tags.
std::string user_id
User identifier associated with the request.

References correlation_id, request_id, tags, and user_id.

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

Here is the caller graph for this function:

◆ get_tag()

std::string kcenon::monitoring::context_metadata::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 92 of file thread_context.h.

92 {
93 auto it = tags.find(key);
94 return it != tags.end() ? it->second : "";
95 }

References tags.

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

Here is the caller graph for this function:

◆ set_tag()

void kcenon::monitoring::context_metadata::set_tag ( const std::string & key,
const std::string & value )
inline

Set a custom tag on this context.

Parameters
keyTag name
valueTag value

Definition at line 83 of file thread_context.h.

83 {
84 tags[key] = value;
85 }

References tags.

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

Here is the caller graph for this function:

Member Data Documentation

◆ correlation_id

std::string kcenon::monitoring::context_metadata::correlation_id

Correlation ID for tracing across services.

Definition at line 59 of file thread_context.h.

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

◆ request_id

std::string kcenon::monitoring::context_metadata::request_id

Unique identifier for the current request.

Definition at line 58 of file thread_context.h.

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

◆ tags

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

Arbitrary key-value tags.

Definition at line 61 of file thread_context.h.

Referenced by empty(), get_tag(), set_tag(), TEST(), and TEST_F().

◆ user_id

std::string kcenon::monitoring::context_metadata::user_id

User identifier associated with the request.

Definition at line 60 of file thread_context.h.

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


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