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<()> { ... }
fn on_thread_stop(&mut self) { ... }
fn segment_metadata(&mut self, out: &mut Vec<(String, String)>) { ... }
}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 SharedState::push_source before starting the flush
thread; the flush thread calls flush once per cycle.
Required Methods§
Sourcefn flush(&mut self, ctx: &FlushContext<'_>)
fn flush(&mut self, ctx: &FlushContext<'_>)
Drain pending data into the trace. Called once per flush cycle.
Provided Methods§
Sourcefn on_thread_start(&mut self) -> Result<()>
fn on_thread_start(&mut self) -> Result<()>
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.
Sourcefn 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.
Sourcefn 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.
Appending nothing on an unchanged cycle is what lets the flush loop skip
the merge (it merges only when out is non-empty), so steady-state
cycles allocate nothing. The default reports a source with no metadata.
Dyn Compatibility§
This trait is dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".