pub enum ProcessorMode {
Sync,
Async,
Finalize,
}Expand description
Controls how spans are processed and exported.
This enum determines when and how OpenTelemetry spans are flushed from the buffer to the configured exporter. Each mode offers different tradeoffs between latency, reliability, and flexibility.
§Modes
-
Sync: Immediate flush in handler thread- Spans are flushed before handler returns
- Direct export without extension coordination
- May be more efficient for small payloads and low memory configurations
- Guarantees span delivery before response
-
Async: Flush via Lambda extension- Spans are flushed after handler returns
- Requires coordination with extension process
- Additional overhead from IPC with extension
- Provides retry capabilities through extension
-
Finalize: Delegated to processor- Spans handled by configured processor
- Compatible with BatchSpanProcessor
- Best for custom export strategies
- Full control over export timing
§Configuration
The mode can be configured using the LAMBDA_EXTENSION_SPAN_PROCESSOR_MODE environment variable:
- “sync” for Sync mode (default)
- “async” for Async mode
- “finalize” for Finalize mode
§Example
use lambda_otel_lite::ProcessorMode;
use std::env;
// Set mode via environment variable
env::set_var("LAMBDA_EXTENSION_SPAN_PROCESSOR_MODE", "async");
// Get mode from environment
let mode = ProcessorMode::from_env();
assert!(matches!(mode, ProcessorMode::Async));Variants§
Sync
Synchronous flush in handler thread. Best for development and debugging.
Async
Asynchronous flush via extension. Best for production use to minimize latency.
Finalize
Let processor handle flushing. Best with BatchSpanProcessor for custom export strategies.
Implementations§
Source§impl ProcessorMode
impl ProcessorMode
Trait Implementations§
Source§impl Clone for ProcessorMode
impl Clone for ProcessorMode
Source§fn clone(&self) -> ProcessorMode
fn clone(&self) -> ProcessorMode
Returns a copy of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for ProcessorMode
impl Debug for ProcessorMode
Source§impl PartialEq for ProcessorMode
impl PartialEq for ProcessorMode
impl StructuralPartialEq for ProcessorMode
Auto Trait Implementations§
impl Freeze for ProcessorMode
impl RefUnwindSafe for ProcessorMode
impl Send for ProcessorMode
impl Sync for ProcessorMode
impl Unpin for ProcessorMode
impl UnwindSafe for ProcessorMode
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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