macro_rules! define_trace_id_fns {
($subscriber:ty) => { ... };
}Expand description
Generates implementations of the functions pointed to by GET_TRACE_ID_FN
and INSERT_TRACE_ID_FN given the type of the tracing::Subscriber.
The caller (typically lexe_logger::try_init()) is responsible for
initializing these statics using the generated implementations.
ⓘ
pub fn try_init() -> anyhow::Result<()> {
FmtSubscriber::new().try_init().context("Logger already set")?;
// Notice how `FmtSubscriber` here exactly matches our subscriber type.
// If using a more complex subscriber, you will have to name the type,
// e.g. `Layered<Filtered<FmtLayer<Registry, ...>, ..., ...>, ...>`.
// See public/logger/src/lib.rs for an example of this.
lexe_common::define_trace_id_fns!(FmtSubscriber);
lexe_api::trace::GET_TRACE_ID_FN
.set(get_trace_id_from_span)
.map_err(|_| anyhow!("GET_TRACE_ID_FN already set"))?;
lexe_api::trace::INSERT_TRACE_ID_FN
.set(insert_trace_id_into_span)
.map_err(|_| anyhow!("INSERT_TRACE_ID_FN already set"))?;
Ok(())
}