pub trait TraceEventSink: Send + 'static {
// Required methods
fn consume(&mut self, event: &TraceEvent) -> Result<(), Error>;
fn flush(&mut self) -> Result<(), Error>;
// Provided methods
fn target_filter(&self) -> Option<&Targets> { ... }
fn name(&self) -> &str { ... }
}Expand description
Trait for sinks that receive trace events from the dispatcher. Implementations run on the background worker thread and can perform expensive I/O operations without blocking the application.
Required Methods§
Provided Methods§
Sourcefn target_filter(&self) -> Option<&Targets>
fn target_filter(&self) -> Option<&Targets>
Optional target/level filter for this sink.
The worker loop automatically applies this filter before calling consume(),
so sinks don’t need to check target/level in their consume implementation.
Only NewSpan and Event are filtered by target/level; other event types
are always passed through.
§Returns
None- No filtering, all events are consumed (default)Some(Targets)- Only consume events matching the target/level filter
§Example
ⓘ
fn target_filter(&self) -> Option<&Targets> {
Some(Targets::new()
.with_target("opentelemetry", LevelFilter::OFF)
.with_default(LevelFilter::DEBUG))
}