pub struct RingBufferSubscriber { /* private fields */ }Expand description
Retains the last capacity trace events in a circular buffer.
Used for time-travel debugging — the dev tools can read the buffer to replay the sequence of events leading up to the current state or a crash.
Default capacity: 1000 events.
Implementations§
Source§impl RingBufferSubscriber
impl RingBufferSubscriber
Sourcepub fn filtered(
capacity: usize,
filter: impl Fn(&RosaceTrace) -> bool + Send + Sync + 'static,
) -> Self
pub fn filtered( capacity: usize, filter: impl Fn(&RosaceTrace) -> bool + Send + Sync + 'static, ) -> Self
A ring buffer that only records events passing filter — the basis
of the always-on flight recorder, which excludes high-frequency
events so it never becomes a per-frame firehose (D123/O1).
Sourcepub fn drain(&self) -> Vec<RosaceTrace>
pub fn drain(&self) -> Vec<RosaceTrace>
Drains all buffered events into a Vec, oldest first.
Sourcepub fn snapshot(&self) -> Vec<RosaceTrace>
pub fn snapshot(&self) -> Vec<RosaceTrace>
Returns a snapshot of all buffered events, oldest first, without clearing.
Sourcepub fn snapshot_timestamped(&self) -> Vec<(Instant, RosaceTrace)>
pub fn snapshot_timestamped(&self) -> Vec<(Instant, RosaceTrace)>
Like Self::snapshot, but pairs each event with the Instant it
was recorded at (D123/O1 — the Perfetto/Chrome trace JSON export
needs a timestamp per event; the events themselves mostly don’t
carry one).
Sourcepub fn export_perfetto_json(&self) -> String
pub fn export_perfetto_json(&self) -> String
Export the current buffer as a Chrome/Perfetto-loadable trace JSON (Trace Event Format) — drop it in Perfetto UI’s “Open trace file” for a full flamegraph, for free (D123/O1).
Trait Implementations§
Source§impl TraceSubscriber for RingBufferSubscriber
impl TraceSubscriber for RingBufferSubscriber
Source§fn on_trace(&self, event: &RosaceTrace)
fn on_trace(&self, event: &RosaceTrace)
RosaceTrace event.