diff --git a/Cargo.lock b/Cargo.lock index 051090efe..f75b57be5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5910,6 +5910,7 @@ version = "0.35.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "fcdaf9b1939589476bd57751d12a9653bbfe356610fc476d03d7683189183ab7" dependencies = [ + "axum", "http 1.2.0", "pin-project", "sentry-core", diff --git a/Cargo.toml b/Cargo.toml index b28d29845..d2b0bed1b 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -17,7 +17,7 @@ exclude = [ ] [dependencies] -sentry = { version = "0.35.0", features = ["panic", "tracing", "tower-http", "anyhow", "backtrace"] } +sentry = { version = "0.35.0", features = ["panic", "tracing", "tower-http", "anyhow", "backtrace", "tower-axum-matched-path"] } log = "0.4" tracing = "0.1.37" tracing-subscriber = { version = "0.3.16", default-features = false, features = ["ansi", "fmt", "json", "env-filter", "tracing-log"] } diff --git a/src/web/mod.rs b/src/web/mod.rs index 702513939..3bc6557a2 100644 --- a/src/web/mod.rs +++ b/src/web/mod.rs @@ -39,7 +39,7 @@ mod status; use crate::{impl_axum_webpage, Context}; use anyhow::Error; use axum::{ - extract::{Extension, MatchedPath, Request as AxumRequest}, + extract::{Extension, Request as AxumRequest}, http::StatusCode, middleware, middleware::Next, @@ -382,23 +382,6 @@ async fn log_timeouts_to_sentry(req: AxumRequest, next: Next) -> AxumResponse { response } -async fn set_sentry_transaction_name_from_axum_route( - request: AxumRequest, - next: Next, -) -> AxumResponse { - let route_name = if let Some(path) = request.extensions().get::() { - path.as_str() - } else { - request.uri().path() - }; - - sentry::configure_scope(|scope| { - scope.set_transaction(Some(route_name)); - }); - - next.run(request).await -} - async fn apply_middleware( router: AxumRouter, context: &C, @@ -415,9 +398,6 @@ async fn apply_middleware( .layer(TraceLayer::new_for_http()) .layer(sentry_tower::NewSentryLayer::new_from_top()) .layer(sentry_tower::SentryHttpLayer::with_transaction()) - .layer(middleware::from_fn( - set_sentry_transaction_name_from_axum_route, - )) .layer(CatchPanicLayer::new()) .layer(option_layer( config