Class TraceSession

Class Documentation

class TraceSession

Class to manage a trace session.

A TraceSession manages the collection of trace events and stores them in a queue. It also handles the writing of the trace events to a file asynchronously via a separate consumer thread.

Public Functions

explicit TraceSession(const std::string &filename)

Construct a new TraceSession object.

Parameters:

filename – The name of the file to write the trace events to.

~TraceSession()

Destroy the TraceSession object and stop tracing.

void stop()

Stop the trace session and flush remaining trace events to the file.

void register_trace(const std::string &trace_name, const std::chrono::nanoseconds &start_time, const std::chrono::nanoseconds &end_time)

Register a new trace event.

This function is called by TraceGuard to register the start and end time of a function execution.

Parameters:
  • trace_name – The name of the function being traced.

  • start_time – The start time of the function execution.

  • end_time – The end time of the function execution.