Skip to main content

GET_TRACE_ID_FN

Static GET_TRACE_ID_FN 

Source
pub static GET_TRACE_ID_FN: OnceLock<fn(&Id, &Dispatch) -> Result<Option<TraceId>>>
Expand description

A function pointer to a fn which attempts to extract a TraceId from the Extensions of the given span or any of its parents.

This static is required because we are required to downcast the Dispatch to a concrete subscriber type (which implements the LookupSpan trait), which we do not know since we are agnostic over tracing::Subscribers. An alternative was to make the RestClient generic over a logger L so that the subscriber type was known when calling client::request_span. However, this results in highly undesirable RestClient ergonomics. Instead, we provide impls for these fns via the define_trace_id_fns macro, and initialize these statics in the try_init() of our loggers.