Trait Source
pub trait Source: Any + Send {
// Required methods
fn flush(&mut self, ctx: &FlushContext<'_>);
fn name(&self) -> &'static str;
// Provided methods
fn on_thread_start(&mut self) -> Result<(), Error> { ... }
fn on_thread_stop(&mut self) { ... }
fn segment_metadata(&mut self, out: &mut Vec<(String, String)>) { ... }
fn segment_processor(&mut self) -> Option<Box<dyn SegmentProcessor>> { ... }
}dial9 only.Expand description
A data source drained by the flush thread each cycle.
Implement this trait to feed custom events into the dial9 trace. Register
the source with RecorderBuilder::source before starting the flush
thread; the flush thread calls flush once per cycle.
Required Methods§
fn flush(&mut self, ctx: &FlushContext<'_>)
fn flush(&mut self, ctx: &FlushContext<'_>)
Drain pending data into the trace. Called once per flush cycle.
Provided Methods§
fn on_thread_start(&mut self) -> Result<(), Error>
fn on_thread_start(&mut self) -> Result<(), Error>
Called when a thread joins the recorder: a Tokio worker’s first poll, or
an explicit Dial9Handle::track_current_thread.
Per-thread sources (e.g. SchedProfiler) use this to begin tracking
the current thread. Returns an error if setup fails.
fn on_thread_stop(&mut self)
fn on_thread_stop(&mut self)
Called when a thread stops. Per-thread sources use this to stop tracking the current thread.
fn segment_metadata(&mut self, out: &mut Vec<(String, String)>)
fn segment_metadata(&mut self, out: &mut Vec<(String, String)>)
Append this source’s segment-metadata entries to out iff they have
changed since the last call.
The flush loop merges only when out is non-empty, so appending nothing
on an unchanged cycle keeps steady-state cycles allocation-free. The
default reports a source with no metadata.
fn segment_processor(&mut self) -> Option<Box<dyn SegmentProcessor>>
Available on crate feature pipeline only.
fn segment_processor(&mut self) -> Option<Box<dyn SegmentProcessor>>
pipeline only.A segment-processing stage this source’s data needs, folded into the recorder’s default pipeline at build. Called once, at build.
A custom pipeline replaces the default outright and does not pick these up; you must chain the stage yourself in those cases.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".