forked from lavina/lavina
1
0
Fork 0

xmpp: add tracing instrumentations

This commit is contained in:
Nikita Vilunov 2024-05-26 13:55:28 +02:00
parent 381b5650bc
commit f02971d407
3 changed files with 8 additions and 0 deletions

View File

@ -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<Event<'static>>, iq: Iq<IqClientBody>) {
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<InfoQuery, IqError> {
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 {

View File

@ -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<Event<'static>>, m: Message<Ignore>) -> Result<()> {
if let Some(Jid {
name: Some(name),

View File

@ -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<Event<'static>>, p: Presence<Ignore>) -> 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<Event<'static>>, 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<Presence<XUser>> {
let a = self.user_handle.join_room(RoomId::try_from(name.0.clone())?).await?;
// TODO handle bans