diff --git a/src/api/server/send.rs b/src/api/server/send.rs index c0c8a0c9..56a17c22 100644 --- a/src/api/server/send.rs +++ b/src/api/server/send.rs @@ -39,7 +39,15 @@ type ResolvedMap = BTreeMap>; /// # `PUT /_matrix/federation/v1/send/{txnId}` /// /// Push EDUs and PDUs to this server. -#[tracing::instrument(skip_all, fields(%client, origin = body.origin().as_str()), name = "send")] +#[tracing::instrument( + name = "send", + level = "debug", + skip_all, + fields( + %client, + origin = body.origin().as_str() + ), +)] pub(crate) async fn send_transaction_message_route( State(services): State, InsecureClientIp(client): InsecureClientIp, diff --git a/src/database/pool.rs b/src/database/pool.rs index b972e763..f5600c36 100644 --- a/src/database/pool.rs +++ b/src/database/pool.rs @@ -12,7 +12,7 @@ use std::{ use async_channel::{QueueStrategy, Receiver, RecvError, Sender}; use conduwuit::{ - debug, debug_warn, defer, err, error, implement, + debug, debug_warn, err, error, implement, result::DebugInspect, trace, utils::sys::compute::{get_affinity, nth_core_available, set_affinity}, @@ -271,9 +271,6 @@ async fn execute(&self, queue: &Sender, cmd: Cmd) -> Result { ), )] fn worker(self: Arc, id: usize, recv: Receiver) { - defer! {{ trace!("worker finished"); }} - trace!("worker spawned"); - self.worker_init(id); self.worker_loop(&recv); } diff --git a/src/service/rooms/auth_chain/mod.rs b/src/service/rooms/auth_chain/mod.rs index f6534825..74064701 100644 --- a/src/service/rooms/auth_chain/mod.rs +++ b/src/service/rooms/auth_chain/mod.rs @@ -79,7 +79,7 @@ impl Service { Ok(event_ids) } - #[tracing::instrument(skip_all, name = "auth_chain")] + #[tracing::instrument(name = "auth_chain", level = "debug", skip_all)] pub async fn get_auth_chain<'a, I>( &'a self, room_id: &RoomId, @@ -179,7 +179,7 @@ impl Service { Ok(full_auth_chain) } - #[tracing::instrument(skip(self, room_id))] + #[tracing::instrument(name = "inner", level = "trace", skip(self, room_id))] async fn get_auth_chain_inner( &self, room_id: &RoomId, diff --git a/src/service/rooms/event_handler/fetch_prev.rs b/src/service/rooms/event_handler/fetch_prev.rs index 0d64e98e..5966aeba 100644 --- a/src/service/rooms/event_handler/fetch_prev.rs +++ b/src/service/rooms/event_handler/fetch_prev.rs @@ -16,7 +16,7 @@ use super::check_room_id; #[implement(super::Service)] #[tracing::instrument( - level = "warn", + level = "debug", skip_all, fields(%origin), )] diff --git a/src/service/rooms/event_handler/fetch_state.rs b/src/service/rooms/event_handler/fetch_state.rs index cc4a3e46..0892655e 100644 --- a/src/service/rooms/event_handler/fetch_state.rs +++ b/src/service/rooms/event_handler/fetch_state.rs @@ -14,7 +14,7 @@ use crate::rooms::short::ShortStateKey; /// on the events #[implement(super::Service)] #[tracing::instrument( - level = "warn", + level = "debug", skip_all, fields(%origin), )] diff --git a/src/service/rooms/event_handler/handle_incoming_pdu.rs b/src/service/rooms/event_handler/handle_incoming_pdu.rs index c2e6ccc9..4e6f0b0c 100644 --- a/src/service/rooms/event_handler/handle_incoming_pdu.rs +++ b/src/service/rooms/event_handler/handle_incoming_pdu.rs @@ -41,7 +41,7 @@ use crate::rooms::timeline::RawPduId; #[implement(super::Service)] #[tracing::instrument( name = "pdu", - level = "warn", + level = "debug", skip_all, fields(%room_id, %event_id), )] diff --git a/src/service/rooms/event_handler/handle_prev_pdu.rs b/src/service/rooms/event_handler/handle_prev_pdu.rs index ad71c173..2bec4eba 100644 --- a/src/service/rooms/event_handler/handle_prev_pdu.rs +++ b/src/service/rooms/event_handler/handle_prev_pdu.rs @@ -14,7 +14,7 @@ use ruma::{CanonicalJsonValue, EventId, OwnedEventId, RoomId, ServerName}; #[allow(clippy::too_many_arguments)] #[tracing::instrument( name = "prev", - level = "warn", + level = "debug", skip_all, fields(%prev_id), )] diff --git a/src/service/rooms/event_handler/resolve_state.rs b/src/service/rooms/event_handler/resolve_state.rs index f21f7b66..8640c582 100644 --- a/src/service/rooms/event_handler/resolve_state.rs +++ b/src/service/rooms/event_handler/resolve_state.rs @@ -18,7 +18,7 @@ use ruma::{ use crate::rooms::state_compressor::CompressedStateEvent; #[implement(super::Service)] -#[tracing::instrument(skip_all, name = "resolve")] +#[tracing::instrument(name = "resolve", level = "debug", skip_all)] pub async fn resolve_state( &self, room_id: &RoomId, diff --git a/src/service/rooms/event_handler/state_at_incoming.rs b/src/service/rooms/event_handler/state_at_incoming.rs index fa2ce1cd..9e7f8d2a 100644 --- a/src/service/rooms/event_handler/state_at_incoming.rs +++ b/src/service/rooms/event_handler/state_at_incoming.rs @@ -16,7 +16,7 @@ use ruma::{state_res::StateMap, OwnedEventId, RoomId, RoomVersionId}; // 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(skip_all, name = "state")] +#[tracing::instrument(name = "state", level = "debug", skip_all)] pub(super) async fn state_at_incoming_degree_one( &self, incoming_pdu: &Arc, @@ -66,7 +66,7 @@ pub(super) async fn state_at_incoming_degree_one( } #[implement(super::Service)] -#[tracing::instrument(skip_all, name = "state")] +#[tracing::instrument(name = "state", level = "debug", skip_all)] pub(super) async fn state_at_incoming_resolved( &self, incoming_pdu: &Arc, diff --git a/src/service/rooms/state_compressor/mod.rs b/src/service/rooms/state_compressor/mod.rs index a61a66a1..532df360 100644 --- a/src/service/rooms/state_compressor/mod.rs +++ b/src/service/rooms/state_compressor/mod.rs @@ -7,7 +7,7 @@ use std::{ use arrayvec::ArrayVec; use conduwuit::{ - at, checked, debug, err, expected, utils, + at, checked, err, expected, utils, utils::{bytes, math::usize_from_f64, stream::IterStream}, Result, }; @@ -117,35 +117,44 @@ impl crate::Service for Service { impl Service { /// Returns a stack with info on shortstatehash, full state, added diff and /// removed diff for the selected shortstatehash and each parent layer. + #[tracing::instrument(name = "load", level = "debug", skip(self))] pub async fn load_shortstatehash_info( &self, shortstatehash: ShortStateHash, ) -> Result { - if let Some(r) = self - .stateinfo_cache - .lock() - .expect("locked") - .get_mut(&shortstatehash) - { + if let Some(r) = self.stateinfo_cache.lock()?.get_mut(&shortstatehash) { return Ok(r.clone()); } let stack = self.new_shortstatehash_info(shortstatehash).await?; - debug!( - ?shortstatehash, - len = %stack.len(), - "cache update" - ); - - self.stateinfo_cache - .lock() - .expect("locked") - .insert(shortstatehash, stack.clone()); + self.cache_shortstatehash_info(shortstatehash, stack.clone()) + .await?; Ok(stack) } + /// Returns a stack with info on shortstatehash, full state, added diff and + /// removed diff for the selected shortstatehash and each parent layer. + #[tracing::instrument( + name = "cache", + level = "debug", + skip_all, + fields( + ?shortstatehash, + stack = stack.len(), + ), + )] + async fn cache_shortstatehash_info( + &self, + shortstatehash: ShortStateHash, + stack: ShortStateInfoVec, + ) -> Result { + self.stateinfo_cache.lock()?.insert(shortstatehash, stack); + + Ok(()) + } + async fn new_shortstatehash_info( &self, shortstatehash: ShortStateHash, diff --git a/src/service/rooms/timeline/mod.rs b/src/service/rooms/timeline/mod.rs index 3ebc432f..bd60e40e 100644 --- a/src/service/rooms/timeline/mod.rs +++ b/src/service/rooms/timeline/mod.rs @@ -259,7 +259,7 @@ impl Service { /// happens in `append_pdu`. /// /// Returns pdu id - #[tracing::instrument(skip_all)] + #[tracing::instrument(level = "debug", skip_all)] pub async fn append_pdu( &self, pdu: &PduEvent, @@ -942,7 +942,7 @@ impl Service { /// Append the incoming event setting the state snapshot to the state from /// the server that sent the event. - #[tracing::instrument(skip_all)] + #[tracing::instrument(level = "debug", skip_all)] pub async fn append_incoming_pdu( &self, pdu: &PduEvent,