Class TraceGuard
Defined in File tracing.hpp
Class Documentation
-
class TraceGuard
Class to manage the trace of a single function execution.
A TraceGuard object is created at the start of a function and destroyed when the function exits, automatically registering the start and end times of the function execution to the associated TraceSession.
Public Functions
-
TraceGuard(TraceSession &session, const std::string &trace_name)
Construct a new TraceGuard object.
This constructor captures the function name and the start time of the function.
- Parameters:
session – The TraceSession to register the trace event with.
trace_name – The name of the function being traced.
-
~TraceGuard()
Destroy the TraceGuard object.
The destructor automatically registers the end time of the function and submits the trace event to the TraceSession.
-
inline std::chrono::nanoseconds get_start_time() const
Retrieve the start time of the trace.
This getter provides read-only access to the start time recorded by the
TraceGuard
at the beginning of a traced function execution.- Returns:
The start time of the function execution as a
std::chrono::nanoseconds
duration.
Protected Functions
-
std::string extract_trace_name(const std::string &function_signature)
Extract the function name from the full function signature.
This function processes the function signature to extract only the relevant function name without parameters.
- Parameters:
function_signature – The full function signature.
- Returns:
The extracted function name.
-
TraceGuard(TraceSession &session, const std::string &trace_name)