pub enum Tracer {
Active(Arc<ActiveTracer>),
Noop,
}Expand description
Performance tracer that emits Chrome Trace Event Format data.
Variants§
Active(Arc<ActiveTracer>)
Actively collecting trace events.
Noop
No-op tracer that discards all events.
Implementations§
Source§impl Tracer
impl Tracer
Sourcepub fn complete_event(
&self,
name: &str,
cat: &str,
pid: u32,
tid: u32,
start_us: f64,
dur_us: f64,
args: Option<Value>,
)
pub fn complete_event( &self, name: &str, cat: &str, pid: u32, tid: u32, start_us: f64, dur_us: f64, args: Option<Value>, )
Records a complete (“X”) event with explicit start time and duration.
Sourcepub fn instant_event(
&self,
name: &str,
cat: &str,
pid: u32,
tid: u32,
args: Option<Value>,
)
pub fn instant_event( &self, name: &str, cat: &str, pid: u32, tid: u32, args: Option<Value>, )
Records an instant (“i”) event with thread scope.
Sourcepub fn metadata_event(&self, name: &str, pid: u32, tid: u32, args: Value)
pub fn metadata_event(&self, name: &str, pid: u32, tid: u32, args: Value)
Records a metadata (“M”) event (e.g. for process_name, thread_name).
Sourcepub fn span(&self, name: &str, cat: &str, pid: u32, tid: u32) -> SpanGuard
pub fn span(&self, name: &str, cat: &str, pid: u32, tid: u32) -> SpanGuard
Creates an RAII span guard that records a complete event on drop.
Sourcepub fn elapsed_us(&self) -> f64
pub fn elapsed_us(&self) -> f64
Returns microseconds elapsed since the tracer epoch (0.0 for Noop).
Sourcepub fn to_json(&self) -> Result<String, Error>
pub fn to_json(&self) -> Result<String, Error>
Serializes all collected events to a JSON array string.
Sourcepub fn write_to_file(&self, path: &Path) -> Result<()>
pub fn write_to_file(&self, path: &Path) -> Result<()>
Writes the JSON trace to a file (no-op for Noop).
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Tracer
impl RefUnwindSafe for Tracer
impl Send for Tracer
impl Sync for Tracer
impl Unpin for Tracer
impl UnsafeUnpin for Tracer
impl UnwindSafe for Tracer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more