pub struct OtelTracingLayerBuilder<E> { /* private fields */ }Expand description
Builder for configuring an OtelTracingLayer.
§Example
use opentelemetry_lambda_tower::{OtelTracingLayer, HttpEventExtractor};
use std::time::Duration;
let layer = OtelTracingLayer::builder(HttpEventExtractor::new())
.tracer_provider(my_provider)
.flush_timeout(Duration::from_secs(10))
.build();Implementations§
Source§impl<E> OtelTracingLayerBuilder<E>
impl<E> OtelTracingLayerBuilder<E>
Sourcepub fn tracer_provider(self, provider: Arc<SdkTracerProvider>) -> Self
pub fn tracer_provider(self, provider: Arc<SdkTracerProvider>) -> Self
Sets the tracer provider to use for flushing.
If not set, the layer will attempt to use the global tracer provider.
Sourcepub fn logger_provider(self, provider: Arc<SdkLoggerProvider>) -> Self
pub fn logger_provider(self, provider: Arc<SdkLoggerProvider>) -> Self
Sets the logger provider to use for flushing.
If not set, logs will not be explicitly flushed after each invocation. This is required if you want to ensure logs are exported before Lambda freezes the execution environment.
Sourcepub fn flush_on_end(self, flush: bool) -> Self
pub fn flush_on_end(self, flush: bool) -> Self
Sets whether to flush the tracer provider after each invocation.
Default: true
Flushing ensures spans are exported before Lambda freezes the execution environment. Disable only if you’re handling flushing elsewhere (e.g., in an extension).
Sourcepub fn flush_timeout(self, timeout: Duration) -> Self
pub fn flush_timeout(self, timeout: Duration) -> Self
Sets the timeout for flush operations.
Default: 5 seconds
If the flush doesn’t complete within this duration, it’s abandoned to prevent blocking the Lambda response.
Sourcepub fn build(self) -> OtelTracingLayer<E>
pub fn build(self) -> OtelTracingLayer<E>
Builds the configured layer.