From daa869fcedc85a66643f10b8947efed78c1b38c4 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Sun, 25 Jan 2026 23:51:00 +0000 Subject: [PATCH] Additional missing tracing spans on state_res::resolve components. Signed-off-by: Jason Volk --- .../state_res/resolve/auth_difference.rs | 1 + .../state_res/resolve/conflicted_subgraph.rs | 10 ++++++++++ .../state_res/resolve/iterative_auth_check.rs | 4 ++-- .../matrix/state_res/resolve/power_sort.rs | 2 ++ .../state_res/resolve/split_conflicted.rs | 1 + .../rooms/event_handler/resolve_state.rs | 18 ++++++++++++++++-- .../rooms/event_handler/state_at_incoming.rs | 6 +++--- 7 files changed, 35 insertions(+), 7 deletions(-) diff --git a/src/core/matrix/state_res/resolve/auth_difference.rs b/src/core/matrix/state_res/resolve/auth_difference.rs index fd6fde1e..92d702fe 100644 --- a/src/core/matrix/state_res/resolve/auth_difference.rs +++ b/src/core/matrix/state_res/resolve/auth_difference.rs @@ -24,6 +24,7 @@ use crate::utils::stream::{IterStream, ReadyExt}; /// ## Returns /// /// Outputs the event IDs that are not present in all the auth chains. +#[tracing::instrument(level = "debug", skip_all)] pub(super) fn auth_difference<'a, AuthSets, Id>(auth_sets: AuthSets) -> impl Stream where AuthSets: Stream>, diff --git a/src/core/matrix/state_res/resolve/conflicted_subgraph.rs b/src/core/matrix/state_res/resolve/conflicted_subgraph.rs index 41f051f9..18649d00 100644 --- a/src/core/matrix/state_res/resolve/conflicted_subgraph.rs +++ b/src/core/matrix/state_res/resolve/conflicted_subgraph.rs @@ -25,6 +25,7 @@ struct Local { stack: Vec>, } +#[tracing::instrument(name = "conflicted_subgraph", level = "debug", skip_all)] pub(super) fn conflicted_subgraph_dfs( conflicted_event_ids: ConflictedEventIds, fetch: &Fetch, @@ -65,6 +66,15 @@ where .flatten_stream() } +#[tracing::instrument( + name = "descent", + level = "trace", + skip_all, + fields( + event_id = %conflicted_event_id, + event_ids = conflicted_event_ids.len(), + ) +)] async fn subgraph_descent( state: Arc, conflicted_event_id: OwnedEventId, diff --git a/src/core/matrix/state_res/resolve/iterative_auth_check.rs b/src/core/matrix/state_res/resolve/iterative_auth_check.rs index 792d2e43..ab4a668a 100644 --- a/src/core/matrix/state_res/resolve/iterative_auth_check.rs +++ b/src/core/matrix/state_res/resolve/iterative_auth_check.rs @@ -79,11 +79,11 @@ where #[tracing::instrument( name = "check", - level = "debug", + level = "trace", skip_all, fields( %event_id, - %state_key, + ?state_key, ) )] async fn auth_check( diff --git a/src/core/matrix/state_res/resolve/power_sort.rs b/src/core/matrix/state_res/resolve/power_sort.rs index 72d081c6..b192cc00 100644 --- a/src/core/matrix/state_res/resolve/power_sort.rs +++ b/src/core/matrix/state_res/resolve/power_sort.rs @@ -98,6 +98,7 @@ where /// Add the event with the given event ID and all the events in its auth chain /// that are in the full conflicted set to the graph. #[tracing::instrument( + name = "auth_chain", level = "trace", skip_all, fields( @@ -182,6 +183,7 @@ where /// Returns the power level of the sender of the event or an `Err(_)` if one of /// the auth events if malformed. #[tracing::instrument( + name = "sender_power", level = "trace", skip_all, fields( diff --git a/src/core/matrix/state_res/resolve/split_conflicted.rs b/src/core/matrix/state_res/resolve/split_conflicted.rs index ee950f65..9313a213 100644 --- a/src/core/matrix/state_res/resolve/split_conflicted.rs +++ b/src/core/matrix/state_res/resolve/split_conflicted.rs @@ -25,6 +25,7 @@ use crate::validated; /// ## Returns /// /// Returns an `(unconflicted_state, conflicted_states)` tuple. +#[tracing::instrument(name = "split", level = "debug", skip_all)] pub(super) async fn split_conflicted_state<'a, Maps, Id>( state_maps: Maps, ) -> (StateMap, StateMap>) diff --git a/src/service/rooms/event_handler/resolve_state.rs b/src/service/rooms/event_handler/resolve_state.rs index 7cefcf80..d001ee10 100644 --- a/src/service/rooms/event_handler/resolve_state.rs +++ b/src/service/rooms/event_handler/resolve_state.rs @@ -13,7 +13,14 @@ use tuwunel_core::{ use crate::rooms::state_compressor::CompressedState; #[implement(super::Service)] -#[tracing::instrument(name = "resolve", level = "debug", skip_all)] +#[tracing::instrument( + name = "state", + level = "debug", + skip_all, + fields( + incoming = ?incoming_state.len() + ), +)] pub async fn resolve_state( &self, room_id: &RoomId, @@ -64,7 +71,7 @@ pub async fn resolve_state( trace!("Resolving state"); let state = self - .state_resolution(room_version, fork_states, auth_chain_sets) + .state_resolution(room_id, room_version, fork_states, auth_chain_sets) .await?; trace!("State resolution done."); @@ -96,8 +103,15 @@ pub async fn resolve_state( } #[implement(super::Service)] +#[tracing::instrument( + name = "resolve", + level = "debug", + skip_all, + fields(%room_id), +)] pub(super) async fn state_resolution( &self, + room_id: &RoomId, room_version: &RoomVersionId, state_sets: StateSets, auth_chains: AuthSets, diff --git a/src/service/rooms/event_handler/state_at_incoming.rs b/src/service/rooms/event_handler/state_at_incoming.rs index 56f88033..386845dd 100644 --- a/src/service/rooms/event_handler/state_at_incoming.rs +++ b/src/service/rooms/event_handler/state_at_incoming.rs @@ -17,7 +17,7 @@ use crate::rooms::short::ShortStateHash; // TODO: if we know the prev_events of the incoming event we can avoid the #[implement(super::Service)] // request and build the state from a known point and resolve if > 1 prev_event -#[tracing::instrument(name = "state", level = "debug", skip_all)] +#[tracing::instrument(name = "state1", level = "debug", skip_all)] pub(super) async fn state_at_incoming_degree_one( &self, incoming_pdu: &Pdu, @@ -96,7 +96,7 @@ where } #[implement(super::Service)] -#[tracing::instrument(name = "state", level = "debug", skip_all)] +#[tracing::instrument(name = "stateN", level = "debug", skip_all)] pub(super) async fn state_at_incoming_resolved( &self, incoming_pdu: &Pdu, @@ -149,7 +149,7 @@ where trace!("Resolving state"); let Ok(new_state) = self - .state_resolution(room_version, fork_states, auth_chain_sets) + .state_resolution(room_id, room_version, fork_states, auth_chain_sets) .inspect_ok(|_| trace!("State resolution done.")) .await else {