pub struct TracingMiddleware {
pub sampling_strategy: SamplingStrategy,
pub sampling_rate: f64,
/* private fields */
}Expand description
Middleware that creates tracing spans around module execution.
Uses a stack-based approach (Vec of Spans per trace_id) to correctly
handle nested module-to-module calls with proper parent-child span
relationships.
Lock ordering: always acquire ctx.data before self.state to prevent
deadlocks.
Fields§
§sampling_strategy: SamplingStrategy§sampling_rate: f64Implementations§
Source§impl TracingMiddleware
impl TracingMiddleware
Sourcepub fn new(exporter: Box<dyn SpanExporter>) -> Self
pub fn new(exporter: Box<dyn SpanExporter>) -> Self
Create a new tracing middleware with the given exporter (Always sampling).
Sourcepub fn with_sampling(
exporter: Box<dyn SpanExporter>,
strategy: SamplingStrategy,
rate: f64,
) -> Self
pub fn with_sampling( exporter: Box<dyn SpanExporter>, strategy: SamplingStrategy, rate: f64, ) -> Self
Create with explicit sampling configuration.
Trait Implementations§
Source§impl Debug for TracingMiddleware
impl Debug for TracingMiddleware
Source§impl Middleware for TracingMiddleware
impl Middleware for TracingMiddleware
Source§fn before<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
module_id: &'life1 str,
_inputs: Value,
ctx: &'life2 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn before<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
module_id: &'life1 str,
_inputs: Value,
ctx: &'life2 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called before module execution. Can modify input.
Return
Ok(None) to pass through unchanged, Ok(Some(v)) to modify.Source§fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_module_id: &'life1 str,
_inputs: Value,
_output: Value,
ctx: &'life2 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn after<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_module_id: &'life1 str,
_inputs: Value,
_output: Value,
ctx: &'life2 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Called after successful module execution. Can modify output.
inputs is the original (post-before) input for correlation.
Return Ok(None) to pass through unchanged, Ok(Some(v)) to modify.Source§fn on_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_module_id: &'life1 str,
_inputs: Value,
error: &'life2 ModuleError,
ctx: &'life3 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
fn on_error<'life0, 'life1, 'life2, 'life3, 'async_trait>(
&'life0 self,
_module_id: &'life1 str,
_inputs: Value,
error: &'life2 ModuleError,
ctx: &'life3 Context<Value>,
) -> Pin<Box<dyn Future<Output = Result<Option<Value>, ModuleError>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
'life3: 'async_trait,
Called when module execution fails.
inputs is the original (post-before) input for correlation.
Return Ok(Some(v)) to signal recovery (retry with those inputs),
or Ok(None) to let the error propagate.Auto Trait Implementations§
impl !Freeze for TracingMiddleware
impl !RefUnwindSafe for TracingMiddleware
impl Send for TracingMiddleware
impl Sync for TracingMiddleware
impl Unpin for TracingMiddleware
impl UnsafeUnpin for TracingMiddleware
impl !UnwindSafe for TracingMiddleware
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