From 0b9e43cbdd1a014651a8ee877d146847e26b58d1 Mon Sep 17 00:00:00 2001 From: Lambda Date: Sun, 2 Jun 2024 14:34:17 +0000 Subject: [PATCH] Record authentication info in incoming requests --- src/main.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 8ae705a3..180f2e03 100644 --- a/src/main.rs +++ b/src/main.rs @@ -38,7 +38,7 @@ use tower_http::{ trace::TraceLayer, ServiceBuilderExt as _, }; -use tracing::{debug, info, warn}; +use tracing::{debug, info, info_span, warn, Instrument}; pub(crate) mod api; pub(crate) mod clap; @@ -570,8 +570,17 @@ macro_rules! impl_ruma_handler { path, on( method_filter, - |$( $ty: $ty, )* req| async move { - handler($($ty,)* req).await + |$( $ty: $ty, )* req: Ar| async move { + let span = info_span!( + "run_ruma_handler", + auth.user = ?req.sender_user, + auth.device = ?req.sender_device, + auth.servername = ?req.sender_servername, + auth.appservice_id = ?req.appservice_info + .as_ref() + .map(|i| &i.registration.id) + ); + handler($($ty,)* req).instrument(span).await } ) )