sync/v3: record relevant span fields

This commit is contained in:
Lambda 2024-05-30 19:16:42 +00:00
parent 79783ebe56
commit 55a04f77c6

View file

@ -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<sync_events::v3::Request>,
) -> Result<Ra<sync_events::v3::Response>, Ra<UiaaResponse>> {
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