Skip to main content

spawn_in_current_span

Function spawn_in_current_span 

Source
pub fn spawn_in_current_span<T>(
    task: impl Future<Output = T> + Send + 'static,
) -> JoinHandle<T>
where T: Send + 'static,
Expand description

Spawn a future on the current tokio runtime, propagating the current tracing span into the spawned task. This ensures that any logs or internal metrics emitted by the task retain the component tags (component_id, component_kind, component_type) of the caller.

Prefer this over tokio::spawn(future.in_current_span()) to keep call sites concise.