Skip to main content

TraceWriter

Struct TraceWriter 

Source
pub struct TraceWriter { /* private fields */ }
Expand description

Buffered, flush-on-drop trace writer.

Events accumulate in memory; flush (called on drop, or explicitly) writes the buffered JSON array to disk. Disabled via the special “no-op” constructor for builds where FERRUM_TRACE_OUT is unset — push becomes a no-op so probe call-sites can call into the writer unconditionally.

Implementations§

Source§

impl TraceWriter

Source

pub fn from_env() -> Self

Construct from env var FERRUM_TRACE_OUT. If unset or empty, returns a disabled writer whose push is a no-op.

Source

pub fn from_env_vars<I, K, V>(vars: I) -> Self
where I: IntoIterator<Item = (K, V)>, K: Into<String>, V: Into<String>,

Source

pub fn enabled(out_path: PathBuf) -> Self

Source

pub fn disabled() -> Self

Source

pub fn is_enabled(&self) -> bool

True if the writer is configured to emit. Probes can use this to skip the BackendTimer overhead entirely when tracing is off.

Source

pub fn push( &self, name: impl Into<String>, cat: impl Into<String>, dur_ms: f64, tid: u32, )

Record a complete event with name, cat, elapsed milliseconds. tid should identify the layer / sub-op (0 for top-level engine).

Source

pub fn push_with_args( &self, name: impl Into<String>, cat: impl Into<String>, dur_ms: f64, tid: u32, args: Map<String, Value>, )

Same as push, but with structured args (e.g. tensor shapes).

Source

pub fn flush(&self) -> Result<()>

Write the buffered events out as a JSON array. Subsequent push calls are buffered into a new file (caller responsibility — flushed writers reset their event buffer).

Trait Implementations§

Source§

impl Drop for TraceWriter

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more
Source§

fn pin_drop(self: Pin<&mut Self>)

🔬This is a nightly-only experimental API. (pin_ergonomics)
Execute the destructor for this type, but different to Drop::drop, it requires self to be pinned. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V