From 55a04f77c67b7af66e82243cf8ae390dd53b6304 Mon Sep 17 00:00:00 2001 From: Lambda Date: Thu, 30 May 2024 19:16:42 +0000 Subject: [PATCH] sync/v3: record relevant span fields --- src/api/client_server/sync/v3.rs | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/src/api/client_server/sync/v3.rs b/src/api/client_server/sync/v3.rs index bcdfb10f..662400a5 100644 --- a/src/api/client_server/sync/v3.rs +++ b/src/api/client_server/sync/v3.rs @@ -23,7 +23,7 @@ use ruma::{ }, uint, DeviceId, EventId, OwnedUserId, RoomId, UInt, UserId, }; -use tracing::{debug, error}; +use tracing::{debug, error, field}; use super::{load_timeline, share_encrypted_room}; use crate::{ @@ -68,17 +68,33 @@ use crate::{ /// - If the user left after `since`: `prev_batch` token, empty state (TODO: /// subset of the state at the point of the leave) #[allow(clippy::too_many_lines)] +#[tracing::instrument( + skip_all, + fields( + sender_user, + sender_device, + next_batch, + since, + lazy_load_enabled, + lazy_load_send_redundant, + ) +)] pub(crate) async fn sync_events_route( body: Ar, ) -> Result, Ra> { + let current_span = tracing::Span::current(); + let sender_user = body.sender_user.expect("user is authenticated"); + current_span.record("sender_user", field::display(&sender_user)); let sender_device = body.sender_device.expect("user is authenticated"); + current_span.record("sender_device", field::display(&sender_device)); let body = body.body; // Setup watchers, so if there's no response, we can wait for them let watcher = services().globals.watch(&sender_user, &sender_device); let next_batch = services().globals.current_count()?; + current_span.record("next_batch", next_batch); let next_batchcount = PduCount::Normal(next_batch); let next_batch_string = next_batch.to_string(); @@ -99,12 +115,15 @@ pub(crate) async fn sync_events_route( } => (true, redundant), LazyLoadOptions::Disabled => (false, false), }; + current_span.record("lazy_load_enabled", lazy_load_enabled); + current_span.record("lazy_load_send_redundant", lazy_load_send_redundant); let full_state = body.full_state; let mut joined_rooms = BTreeMap::new(); let since = body.since.as_ref().and_then(|string| string.parse().ok()).unwrap_or(0); + current_span.record("since", since); let sincecount = PduCount::Normal(since); // Users that have left any encrypted rooms the sender was in