pub struct LambdaSpanProcessor { /* private fields */ }Expand description
Lambda-optimized span processor implementation.
This processor is designed specifically for AWS Lambda functions, providing:
- Efficient span storage through a ring buffer
- Configurable processing modes for different use cases
- Thread-safe operations for concurrent span submission
- Automatic span sampling and filtering
- Batch export capabilities
§Memory Usage
The processor uses a fixed amount of memory based on the configured queue size:
- Each span typically uses 100-500 bytes
- Default configuration (2048 spans) uses 0.5-1MB
- When buffer is full, new spans are dropped with warnings
§Thread Safety
All operations are thread-safe through:
- Mutex protection for span buffer access
- Atomic operations for state management
- Safe sharing between threads with Arc
§Example
use lambda_otel_lite::{LambdaSpanProcessor, ProcessorConfig};
use otlp_stdout_span_exporter::OtlpStdoutSpanExporter;
let processor = LambdaSpanProcessor::new(
Box::new(OtlpStdoutSpanExporter::default()),
ProcessorConfig::default(),
);
// Processor can be safely shared between threads
let processor = std::sync::Arc::new(processor);§Error Handling
The processor handles errors gracefully:
- Export failures are logged but don’t fail the function
- Dropped spans are counted and logged with warnings
- Buffer overflow warnings help with capacity planning
Implementations§
Source§impl LambdaSpanProcessor
impl LambdaSpanProcessor
Sourcepub fn new(exporter: Box<dyn SpanExporter>, config: ProcessorConfig) -> Self
pub fn new(exporter: Box<dyn SpanExporter>, config: ProcessorConfig) -> Self
Creates a new LambdaSpanProcessor with the given configuration
Trait Implementations§
Source§impl Debug for LambdaSpanProcessor
impl Debug for LambdaSpanProcessor
Source§impl SpanProcessor for LambdaSpanProcessor
impl SpanProcessor for LambdaSpanProcessor
Source§fn on_start(&self, _span: &mut Span, _cx: &Context)
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)
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<()>
fn force_flush(&self) -> TraceResult<()>
Force the spans lying in the cache to be exported.
Source§fn shutdown(&self) -> TraceResult<()>
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. Read more
Source§fn set_resource(&mut self, resource: &Resource)
fn set_resource(&mut self, resource: &Resource)
Set the resource for the log processor.
Auto Trait Implementations§
impl !Freeze for LambdaSpanProcessor
impl RefUnwindSafe for LambdaSpanProcessor
impl Send for LambdaSpanProcessor
impl Sync for LambdaSpanProcessor
impl Unpin for LambdaSpanProcessor
impl UnwindSafe for LambdaSpanProcessor
Blanket Implementations§
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
Mutably borrows from an owned value. Read more
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
Wrap the input message
T in a tonic::Request