Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"] }
Expand Down
22 changes: 1 addition & 21 deletions src/web/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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::<MatchedPath>() {
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<C: Context>(
router: AxumRouter,
context: &C,
Expand All @@ -415,9 +398,6 @@ async fn apply_middleware<C: Context>(
.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
Expand Down
Loading