Skip to main content

with_request_id

Function with_request_id 

Source
pub async fn with_request_id<F>(
    id: Option<String>,
    f: F,
) -> <F as Future>::Output
where F: Future,
Expand description

Run f with id installed as current_request_id, so toolkit-http requests made while serving this request carry the same x-request-id downstream. None installs an empty scope: nothing propagates.

id is a tokio task-local, so it is not inherited across tokio::spawn / spawn_blocking or into a streamed body polled after f resolves — such work is uncorrelated unless it captures current_request_id and re-installs it via with_request_id (as tracing::Span needs .in_current_span()).