mz_orchestratord::metrics

Function add_tracing_layer

Source
fn add_tracing_layer<S>(router: Router<S>) -> Router<S>
where S: Clone + Send + Sync + 'static,
Expand description

Adds a tracing layer that reports an INFO level span per request and reports a WARN event when a handler returns a server error to the given Axum Router

This accepts a router instead of returning a layer itself to avoid dealing with defining generics over a bunch of closures (see https://users.rust-lang.org/t/how-to-encapsulate-a-builder-that-depends-on-a-closure/71139/6)

And this also can’t be returned as a Router::new()::layer(TraceLayer)… because the TraceLayer needs to be added to a Router after all routes are defined, as it won’t trace any routes defined on the router after it’s attached.