File tree 1 file changed +7
-2
lines changed
1 file changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -291,6 +291,7 @@ pub fn build_router(
291
291
router = router. fallback ( mas_handlers:: fallback) ;
292
292
293
293
router
294
+ . layer ( axum:: middleware:: from_fn ( log_response_middleware) )
294
295
. layer (
295
296
InFlightCounterLayer :: new ( "http.server.active_requests" ) . on_request ( (
296
297
name. map ( |name| KeyValue :: new ( MAS_LISTENER_NAME , name. to_owned ( ) ) ) ,
@@ -316,12 +317,16 @@ pub fn build_router(
316
317
span. record ( "otel.status_code" , "OK" ) ;
317
318
} ) ,
318
319
)
319
- . layer ( axum:: middleware:: from_fn ( log_response_middleware) )
320
320
. layer ( mas_context:: LogContextLayer :: new ( |req| {
321
321
otel_http_method ( req) . into ( )
322
322
} ) )
323
- . layer ( NewSentryLayer :: new_from_top ( ) )
323
+ // Careful about the order here: the `NewSentryLayer` must be around the
324
+ // `SentryHttpLayer`. axum makes new layers wrap the existing ones,
325
+ // which is the other way around compared to `tower::ServiceBuilder`.
326
+ // So even if the Sentry docs has an example that does
327
+ // 'NewSentryHttpLayer then SentryHttpLayer', we must do the opposite.
324
328
. layer ( SentryHttpLayer :: with_transaction ( ) )
329
+ . layer ( NewSentryLayer :: new_from_top ( ) )
325
330
. with_state ( state)
326
331
}
327
332
You can’t perform that action at this time.
0 commit comments