tokio-rs / axum

Ergonomic and modular web framework built with Tokio, Tower, and Hyper
18.35k stars 1.03k forks source link

Built in support for tracing #2882

Closed Diggsey closed 4 weeks ago

Diggsey commented 4 weeks ago

Feature Request

At the moment I'm using tower_http::TraceLayer::new_for_http() to record tracing events for an axum application. However, this has the problem that span names contain the full URL including URL parameters substituted in. I would like to be able to record spans with placeholders for the URL parameters. This requires knowledge of the router, and so can only be done by axum itself.

jplatte commented 4 weeks ago

tower_http's TraceLayer has many ways in which it can be customized, including a completely custom span. See this example for how to add the matched route path to it.