pub struct OtelTracingLayer<E> { /* private fields */ }Expand description
Tower layer that adds OpenTelemetry tracing to Lambda handlers.
This layer wraps a service with tracing instrumentation that:
- Extracts trace context from Lambda events
- Creates spans with semantic attributes following OTel conventions
- Handles cold start detection
- Flushes the tracer provider after each invocation
§Type Parameters
E- The trace context extractor type
§Example
ⓘ
use opentelemetry_lambda_tower::{OtelTracingLayer, HttpEventExtractor};
use tower::ServiceBuilder;
let layer = OtelTracingLayer::new(HttpEventExtractor::new());
let service = ServiceBuilder::new()
.layer(layer)
.service(my_handler);Implementations§
Source§impl<E> OtelTracingLayer<E>
impl<E> OtelTracingLayer<E>
Sourcepub fn new(extractor: E) -> Self
pub fn new(extractor: E) -> Self
Creates a new tracing layer with the given extractor.
Uses default settings:
- Flush on end: enabled
- Flush timeout: 5 seconds
- No tracer provider (uses global provider)
- No logger provider (logs not flushed)
Sourcepub fn builder(extractor: E) -> OtelTracingLayerBuilder<E>
pub fn builder(extractor: E) -> OtelTracingLayerBuilder<E>
Creates a builder for more detailed configuration.
Trait Implementations§
Source§impl<E: Clone> Clone for OtelTracingLayer<E>
impl<E: Clone> Clone for OtelTracingLayer<E>
Source§fn clone(&self) -> OtelTracingLayer<E>
fn clone(&self) -> OtelTracingLayer<E>
Returns a duplicate 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 moreAuto Trait Implementations§
impl<E> Freeze for OtelTracingLayer<E>where
E: Freeze,
impl<E> !RefUnwindSafe for OtelTracingLayer<E>
impl<E> Send for OtelTracingLayer<E>where
E: Send,
impl<E> Sync for OtelTracingLayer<E>where
E: Sync,
impl<E> Unpin for OtelTracingLayer<E>where
E: Unpin,
impl<E> !UnwindSafe for OtelTracingLayer<E>
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