Macro with_event_from_span

Source
macro_rules! with_event_from_span {
    ($id:ident, $span:ident, $($field:literal = $value:expr),*, |$event:ident| $code:block) => { ... };
}
Expand description

Macro for creating synthetic events from span data.

This macro creates a new tracing event that appears to come from a specific span, allowing for rich span lifecycle logging with custom fields.

§Arguments

  • $id - The span ID
  • $span - The span reference
  • $field:literal = $value:expr - Field-value pairs to include in the event
  • |$event| $code:block - Closure that receives the created event

§Example

with_event_from_span!(
    span_id, 
    span_ref, 
    "message" = "span_entered", 
    "duration" = elapsed_time,
    |event| {
        // Handle the synthetic event
        self.on_event(&event, ctx);
    }
);