Trait opentelemetry_sdk::trace::SpanProcessor

source ·
pub trait SpanProcessor:
    Send
    + Sync
    + Debug {
    // Required methods
    fn on_start(&self, span: &mut Span, cx: &Context);
    fn on_end(&self, span: SpanData);
    fn force_flush(&self) -> TraceResult<()>;
    fn shutdown(&self) -> TraceResult<()>;

    // Provided method
    fn set_resource(&mut self, _resource: &Resource) { ... }
}
Expand description

SpanProcessor is an interface which allows hooks for span start and end method invocations. The span processors are invoked only when is_recording is true.

Required Methods§

source

fn on_start(&self, span: &mut Span, cx: &Context)

on_start is called when a Span is started. This method is called synchronously on the thread that started the span, therefore it should not block or throw exceptions.

source

fn on_end(&self, span: SpanData)

on_end is called after a Span is ended (i.e., the end timestamp is already set). This method is called synchronously within the Span::end API, therefore it should not block or throw an exception.

source

fn force_flush(&self) -> TraceResult<()>

Force the spans lying in the cache to be exported.

source

fn shutdown(&self) -> TraceResult<()>

Shuts down the processor. Called when SDK is shut down. This is an opportunity for processors to do any cleanup required.

Implementation should make sure shutdown can be called multiple times.

Provided Methods§

source

fn set_resource(&mut self, _resource: &Resource)

Set the resource for the log processor.

Implementors§