From 928871d16e0db226afddf36dde36bbbe4a7aacd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Damir=20Jeli=C4=87?= Date: Mon, 16 Jan 2023 14:16:16 +0100 Subject: [PATCH] chore(sdk): Log the request body for sliding sync requests --- crates/matrix-sdk/src/http_client.rs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/crates/matrix-sdk/src/http_client.rs b/crates/matrix-sdk/src/http_client.rs index ca86dfe02..ba8e4ea93 100644 --- a/crates/matrix-sdk/src/http_client.rs +++ b/crates/matrix-sdk/src/http_client.rs @@ -253,7 +253,7 @@ impl HttpClient { #[instrument( skip(self, access_token, config, request, user_id), - fields(config, path, user_id, request_id, status) + fields(config, path, user_id, request_body, request_id, status) )] pub async fn send( &self, @@ -302,6 +302,15 @@ impl HttpClient { span.record("path", request.uri().path()); + // Since sliding sync is experimental, and the proxy might not do what we expect + // it to do given a specific request body, it's useful to log the + // request body here. This doesn't contain any personal information. + // TODO: Remove this once sliding sync isn't experimental anymore. + #[cfg(feature = "experimental-sliding-sync")] + if type_name::() == "ruma_client_api::sync::sync_events::v4::Request" { + span.record("request_body", debug(request.body())); + } + debug!("Sending request"); match self.send_request::(request, config).await { Ok((status_code, response)) => {