From f02971d40759d5a9c55af9dab7a584541edcc50f Mon Sep 17 00:00:00 2001 From: Nikita Vilunov Date: Sun, 26 May 2024 13:55:28 +0200 Subject: [PATCH] xmpp: add tracing instrumentations --- crates/projection-xmpp/src/iq.rs | 4 ++++ crates/projection-xmpp/src/message.rs | 1 + crates/projection-xmpp/src/presence.rs | 3 +++ 3 files changed, 8 insertions(+) diff --git a/crates/projection-xmpp/src/iq.rs b/crates/projection-xmpp/src/iq.rs index d16678f..19b6dbb 100644 --- a/crates/projection-xmpp/src/iq.rs +++ b/crates/projection-xmpp/src/iq.rs @@ -16,6 +16,7 @@ use crate::proto::IqClientBody; use crate::XmppConnection; impl<'a> XmppConnection<'a> { + #[tracing::instrument(skip(self, output, iq), name = "XmppConnection::handle_iq")] pub async fn handle_iq(&self, output: &mut Vec>, iq: Iq) { match iq.body { IqClientBody::Bind(req) => { @@ -112,6 +113,7 @@ impl<'a> XmppConnection<'a> { } } + #[tracing::instrument(skip(self), name = "XmppConnection::bind")] pub(crate) async fn bind(&self, req: &BindRequest) -> BindResponse { BindResponse(Jid { name: Some(self.user.xmpp_name.clone()), @@ -120,6 +122,7 @@ impl<'a> XmppConnection<'a> { }) } + #[tracing::instrument(skip(self), name = "XmppConnection::disco_info")] async fn disco_info(&self, to: Option<&Jid>, req: &InfoQuery) -> Result { let identity; let feature; @@ -199,6 +202,7 @@ impl<'a> XmppConnection<'a> { }) } + #[tracing::instrument(skip(self, core), name = "XmppConnection::disco_items")] async fn disco_items(&self, to: Option<&Jid>, req: &ItemQuery, core: &LavinaCore) -> ItemQuery { let item = match to { Some(Jid { diff --git a/crates/projection-xmpp/src/message.rs b/crates/projection-xmpp/src/message.rs index 1d6fc1d..8557fbf 100644 --- a/crates/projection-xmpp/src/message.rs +++ b/crates/projection-xmpp/src/message.rs @@ -12,6 +12,7 @@ use proto_xmpp::xml::{Ignore, ToXml}; use crate::XmppConnection; impl<'a> XmppConnection<'a> { + #[tracing::instrument(skip(self, output, m), name = "XmppConnection::message")] pub async fn handle_message(&mut self, output: &mut Vec>, m: Message) -> Result<()> { if let Some(Jid { name: Some(name), diff --git a/crates/projection-xmpp/src/presence.rs b/crates/projection-xmpp/src/presence.rs index 2a0986d..5b34e5e 100644 --- a/crates/projection-xmpp/src/presence.rs +++ b/crates/projection-xmpp/src/presence.rs @@ -12,6 +12,7 @@ use proto_xmpp::xml::{Ignore, ToXml}; use crate::XmppConnection; impl<'a> XmppConnection<'a> { + #[tracing::instrument(skip(self, output, p), name = "XmppConnection::handle_presence")] pub async fn handle_presence(&mut self, output: &mut Vec>, p: Presence) -> Result<()> { match p.to { None => { @@ -61,6 +62,7 @@ impl<'a> XmppConnection<'a> { Ok(()) } + #[tracing::instrument(skip(self, output, r#type), name = "XmppConnection::self_presence")] async fn self_presence(&mut self, output: &mut Vec>, r#type: Option<&str>) { match r#type { Some("unavailable") => { @@ -88,6 +90,7 @@ impl<'a> XmppConnection<'a> { } } + #[tracing::instrument(skip(self), name = "XmppConnection::retrieve_muc_presence")] async fn retrieve_muc_presence(&mut self, name: &Name) -> Result> { let a = self.user_handle.join_room(RoomId::try_from(name.0.clone())?).await?; // TODO handle bans