chronon::observe::PerfettoTraceWriter
Perfetto trace writer for the small TracePacket subset chronon needs. More...
#include <PerfettoTraceWriter.hpp>
Public Functions
| Name | |
|---|---|
| ~PerfettoTraceWriter() | |
| void | sliceComplete(uint64_t track_uuid, std::string_view category, std::string_view name, uint64_t ts_ns, uint64_t dur_ns, uint64_t cycle, std::string_view detail ={}) Emit a complete slice (paired SLICE_BEGIN / SLICE_END packets). |
| PerfettoTraceWriter & | operator=(const PerfettoTraceWriter & ) =delete |
| bool | open(const std::filesystem::path & path) Opens path for writing; emits the sequence-start packet. |
| bool | isOpen() const |
| void | instant(uint64_t track_uuid, std::string_view category, std::string_view name, uint64_t ts_ns) Emit an instant event at ts_ns. |
| void | flush() Writes buffered packets to the OS; does not close the file. |
| uint64_t | eventsWritten() const |
| void | counterValue(uint64_t track_uuid, uint64_t ts_ns, int64_t value) Emit a counter sample on a counter track. |
| void | close() |
| uint64_t | bytesWritten() const |
| uint64_t | addTrack(std::string_view name, uint64_t parent_uuid =0) |
| uint64_t | addProcessTrack(std::string_view process_name, int32_t pid) |
| uint64_t | addCounterTrack(std::string_view name, std::string_view unit_name, uint64_t parent_uuid =0) |
| PerfettoTraceWriter() | |
| PerfettoTraceWriter(const PerfettoTraceWriter & ) =delete |
Detailed Description
class chronon::observe::PerfettoTraceWriter;
Perfetto trace writer for the small TracePacket subset chronon needs.
Thin wrapper over the Perfetto SDK's protozero message writers: TrackDescriptor (process / plain / counter tracks) and TrackEvent (complete slices, instants, counter samples). Output opens directly in ui.perfetto.dev and trace_processor. The SDK is an implementation detail (pimpl) and does not leak into chronon headers; no tracing session or category registration is involved — packets are written straight to the file.
Timestamps are nanoseconds on the default trace clock. Simulation-domain events use timestamp = cycle (1 cycle rendered as 1 ns); wall-clock-domain events use real nanoseconds since their recorder's base time. The cycle debug annotation carries the simulation cycle for slices where the two differ.
Packets buffer in memory and flush to disk past a threshold, so the file is written incrementally and remains parseable after a crash (Perfetto traces need no footer). NOT thread-safe; intended for a single backend thread.
Public Functions Documentation
function ~PerfettoTraceWriter
~PerfettoTraceWriter()
function sliceComplete
void sliceComplete(
uint64_t track_uuid,
std::string_view category,
std::string_view name,
uint64_t ts_ns,
uint64_t dur_ns,
uint64_t cycle,
std::string_view detail ={}
)
Emit a complete slice (paired SLICE_BEGIN / SLICE_END packets).
cycle is attached as a debug annotation; detail likewise when non-empty.
function operator=
PerfettoTraceWriter & operator=(
const PerfettoTraceWriter &
) =delete
function open
bool open(
const std::filesystem::path & path
)
Opens path for writing; emits the sequence-start packet.
function isOpen
bool isOpen() const
function instant
void instant(
uint64_t track_uuid,
std::string_view category,
std::string_view name,
uint64_t ts_ns
)
Emit an instant event at ts_ns.
function flush
void flush()
Writes buffered packets to the OS; does not close the file.
function eventsWritten
inline uint64_t eventsWritten() const
function counterValue
void counterValue(
uint64_t track_uuid,
uint64_t ts_ns,
int64_t value
)
Emit a counter sample on a counter track.
function close
void close()
function bytesWritten
inline uint64_t bytesWritten() const
function addTrack
uint64_t addTrack(
std::string_view name,
uint64_t parent_uuid =0
)
Return: Track UUID for a named track, optionally nested under parent_uuid.
function addProcessTrack
uint64_t addProcessTrack(
std::string_view process_name,
int32_t pid
)
Return: Track UUID for a process-scoped group track (ProcessDescriptor).
function addCounterTrack
uint64_t addCounterTrack(
std::string_view name,
std::string_view unit_name,
uint64_t parent_uuid =0
)
Return: Track UUID for a counter track (rendered as a value graph).
function PerfettoTraceWriter
PerfettoTraceWriter()
function PerfettoTraceWriter
PerfettoTraceWriter(
const PerfettoTraceWriter &
) =delete
Updated on 2026-06-12 at 02:36:09 +0000