diff --git a/src/service/sending/mod.rs b/src/service/sending/mod.rs index a799251d..1f3d19ea 100644 --- a/src/service/sending/mod.rs +++ b/src/service/sending/mod.rs @@ -224,17 +224,17 @@ impl Service { Ok(()) } - #[tracing::instrument(skip(self, destination, request))] - pub async fn send_federation_request(&self, destination: &ServerName, request: T) -> Result + #[tracing::instrument(skip(self, request), name = "request")] + pub async fn send_federation_request(&self, dest: &ServerName, request: T) -> Result where T: OutgoingRequest + Debug, { let permit = self.maximum_requests.acquire().await; let timeout = Duration::from_secs(self.timeout); - let response = tokio::time::timeout(timeout, send::send_request(destination, request)) + let response = tokio::time::timeout(timeout, send::send_request(dest, request)) .await .map_err(|_| { - warn!("Timeout after 300 seconds waiting for server response of {destination}"); + warn!("Timeout after 300 seconds waiting for server response of {dest}"); Error::BadServerResponse("Timeout after 300 seconds waiting for server response") })?; drop(permit); @@ -269,6 +269,7 @@ impl Service { }); } + #[tracing::instrument(skip(self), name = "sender")] async fn handler(&self) -> Result<()> { let mut receiver = self.receiver.lock().await; @@ -583,7 +584,6 @@ pub fn select_edus_receipts( Ok(true) } -#[tracing::instrument(skip(events, kind))] async fn handle_events( kind: OutgoingKind, events: Vec, ) -> Result { @@ -743,9 +743,9 @@ async fn handle_events_kind_push( Ok(kind.clone()) } -#[tracing::instrument(skip(kind, events))] +#[tracing::instrument(skip(kind, events), name = "")] async fn handle_events_kind_normal( - kind: &OutgoingKind, server: &OwnedServerName, events: Vec, + kind: &OutgoingKind, dest: &OwnedServerName, events: Vec, ) -> Result { let mut edu_jsons = Vec::new(); let mut pdu_jsons = Vec::new(); @@ -761,7 +761,7 @@ async fn handle_events_kind_normal( .get_pdu_json_from_id(pdu_id) .map_err(|e| (kind.clone(), e))? .ok_or_else(|| { - error!("event not found: {server} {pdu_id:?}"); + error!("event not found: {dest} {pdu_id:?}"); ( kind.clone(), Error::bad_database("[Normal] Event in servernamevent_datas not found in db."), @@ -784,7 +784,7 @@ async fn handle_events_kind_normal( let permit = services().sending.maximum_requests.acquire().await; let response = send::send_request( - server, + dest, send_transaction_message::v1::Request { origin: services().globals.server_name().to_owned(), pdus: pdu_jsons, @@ -806,7 +806,7 @@ async fn handle_events_kind_normal( .map(|response| { for pdu in response.pdus { if pdu.1.is_err() { - warn!("Failed to send to {}: {:?}", server, pdu); + warn!("Failed to send to {}: {:?}", dest, pdu); } } kind.clone() diff --git a/src/service/sending/send.rs b/src/service/sending/send.rs index 68b6b2b2..cee1fc43 100644 --- a/src/service/sending/send.rs +++ b/src/service/sending/send.rs @@ -43,6 +43,7 @@ pub enum FedDest { Named(String, String), } +#[tracing::instrument(skip_all, name = "send")] pub(crate) async fn send_request(destination: &ServerName, request: T) -> Result where T: OutgoingRequest + Debug, @@ -100,7 +101,7 @@ where } else { write_destination_to_cache = true; - let result = find_actual_destination(destination).await; + let result = resolve_actual_destination(destination).await; (result.0, result.1.into_uri_string()) }; @@ -338,7 +339,8 @@ fn add_port_to_hostname(destination_str: &str) -> FedDest { /// Implemented according to the specification at /// Numbers in comments below refer to bullet points in linked section of /// specification -async fn find_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDest) { +#[tracing::instrument(skip_all, name = "resolve")] +async fn resolve_actual_destination(destination: &'_ ServerName) -> (FedDest, FedDest) { debug!("Finding actual destination for {destination}"); let destination_str = destination.as_str().to_owned(); let mut hostname = destination_str.clone();