TraceEventSink

Trait TraceEventSink 

Source
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§

Source

fn consume(&mut self, event: &TraceEvent) -> Result<(), Error>

Consume a single event. Called on background thread.

Source

fn flush(&mut self) -> Result<(), Error>

Flush any buffered events to the backend. Called periodically and on shutdown.

Provided Methods§

Source

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))
}
Source

fn name(&self) -> &str

Optional: return name for debugging/logging

Implementors§