Struct BatchSpanProcessor
pub struct BatchSpanProcessor { /* private fields */ }Expand description
The BatchSpanProcessor collects finished spans in a buffer and exports them
in batches to the configured SpanExporter. This processor is ideal for
high-throughput environments, as it minimizes the overhead of exporting spans
individually. It uses a dedicated background thread to manage and export spans
asynchronously, ensuring that the application’s main execution flow is not blocked.
This processor supports the following configurations:
- Queue size: Maximum number of spans that can be buffered.
- Batch size: Maximum number of spans to include in a single export.
- Scheduled delay: Frequency at which the batch is exported.
When using this processor with the OTLP Exporter, the following exporter features are supported:
grpc-tonic: RequiresTracerProviderto be created within a tokio runtime.reqwest-blocking-client: Works with a regularmainortokio::main.
In other words, other clients like reqwest and hyper are not supported.
BatchSpanProcessor buffers spans in memory and exports them in batches. An
export is triggered when max_export_batch_size is reached or every
scheduled_delay milliseconds. Users can explicitly trigger an export using
the force_flush method. Shutdown also triggers an export of all buffered
spans and is recommended to be called before the application exits to ensure
all buffered spans are exported.
Warning: When using tokio’s current-thread runtime, shutdown(), which
is a blocking call ,should not be called from your main thread. This can
cause deadlock. Instead, call shutdown() from a separate thread or use
tokio’s spawn_blocking.
Implementations§
§impl BatchSpanProcessor
impl BatchSpanProcessor
pub fn new<E>(exporter: E, config: BatchConfig) -> BatchSpanProcessorwhere
E: SpanExporter + Send + 'static,
pub fn new<E>(exporter: E, config: BatchConfig) -> BatchSpanProcessorwhere
E: SpanExporter + Send + 'static,
Creates a new instance of BatchSpanProcessor.
pub fn builder<E>(exporter: E) -> BatchSpanProcessorBuilder<E>where
E: SpanExporter + Send + 'static,
pub fn builder<E>(exporter: E) -> BatchSpanProcessorBuilder<E>where
E: SpanExporter + Send + 'static,
builder
Trait Implementations§
§impl Debug for BatchSpanProcessor
impl Debug for BatchSpanProcessor
§impl SpanProcessor for BatchSpanProcessor
impl SpanProcessor for BatchSpanProcessor
§fn force_flush(&self) -> Result<(), OTelSdkError>
fn force_flush(&self) -> Result<(), OTelSdkError>
Flushes all pending spans.
§fn shutdown_with_timeout(&self, timeout: Duration) -> Result<(), OTelSdkError>
fn shutdown_with_timeout(&self, timeout: Duration) -> Result<(), OTelSdkError>
Shuts down the processor.
§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Set the resource for the processor.
§fn shutdown(&self) -> Result<(), OTelSdkError>
fn shutdown(&self) -> Result<(), OTelSdkError>
Auto Trait Implementations§
impl !Freeze for BatchSpanProcessor
impl RefUnwindSafe for BatchSpanProcessor
impl Send for BatchSpanProcessor
impl Sync for BatchSpanProcessor
impl Unpin for BatchSpanProcessor
impl UnsafeUnpin for BatchSpanProcessor
impl UnwindSafe for BatchSpanProcessor
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
fn with_context(self, otel_cx: Context) -> WithContext<Self> ⓘ
§fn with_current_context(self) -> WithContext<Self> ⓘ
fn with_current_context(self) -> WithContext<Self> ⓘ
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a rama_grpc::Request§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§fn and<P, B, E>(self, other: P) -> And<T, P>
fn and<P, B, E>(self, other: P) -> And<T, P>
Policy that returns Action::Follow only if self and other return
Action::Follow. Read more