katra-trace 0.1.0

Katra3D trace format: versioned, deterministic, correlated event capture.
Documentation
//! Trace records.

use katra_core::TraceEvent;
use serde::{Deserialize, Serialize};

/// One record in a trace stream.
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
pub enum TraceRecord {
    /// A captured event.
    Event(TraceEvent),
    /// An epoch boundary (loading, frame N, scene change, ...). Epochs
    /// segment the trace for per-epoch critical-path analysis.
    EpochMarker {
        /// Epoch label.
        label: String,
        /// Monotonic ns (relative to profiler start).
        ts_mono_ns: u64,
        /// Wall-clock ns.
        ts_wall_ns: u64,
    },
    /// A named counter value at a point in time (bytes copied, queue depth).
    Counter {
        /// Counter name.
        name: String,
        /// Counter value.
        value: u64,
        /// Monotonic ns.
        ts_mono_ns: u64,
    },
    /// End-of-session summary written by the profiler on finish.
    SessionSummary(TraceSummary),
}

/// Session summary written at trace end.
#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)]
pub struct TraceSummary {
    /// Total events captured.
    pub event_count: u64,
    /// Session duration in ns.
    pub duration_ns: u64,
    /// Span pairs completed.
    pub span_count: u64,
    /// Distinct requests correlated.
    pub request_count: u64,
    /// Counter records emitted.
    pub counter_events: u64,
    /// Capture overhead measured during the session (ns).
    pub overhead_ns: u64,
    /// Events dropped due to buffer overflow or post-finish emission.
    pub dropped: u64,
}