add instrumentation to chat functions

This commit is contained in:
DSeeLP 2025-03-16 10:58:24 +01:00
parent 0d5a182e4f
commit 6e9f12c97b

View File

@ -2,6 +2,7 @@ use chrono::{DateTime, Utc};
use deadpool_postgres::GenericClient;
use serde::Serialize;
use tokio_postgres::Row;
use tracing::instrument;
use uuid::{NoContext, Timestamp, Uuid};
use crate::api::{Pagination, PaginationType, RequestPagination};
@ -74,6 +75,7 @@ impl From<Row> for ChatMessage {
}
impl Chat {
#[instrument(skip(client))]
pub async fn exists(
client: &impl GenericClient,
id: Uuid,
@ -85,6 +87,7 @@ impl Chat {
Ok(result.get(0))
}
#[instrument(skip(client))]
pub async fn exists_and_has_access(
client: &impl GenericClient,
id: Uuid,
@ -99,6 +102,7 @@ impl Chat {
Ok(result.get::<_, bool>(0).then_some(result.get(1)))
}
#[instrument(skip(client))]
pub async fn get_by_id(
client: &impl GenericClient,
id: Uuid,
@ -117,6 +121,7 @@ impl Chat {
Ok(result.map(|v| v.get(0)))
}
#[instrument(skip(client))]
pub async fn start(
client: &mut impl GenericClient,
initiator: Uuid,
@ -147,6 +152,7 @@ impl Chat {
})
}
#[instrument(skip(client))]
pub async fn list_for_user(
client: &impl GenericClient,
user: Uuid,
@ -164,6 +170,7 @@ impl Chat {
Ok(Pagination::new(result, total, pagination))
}
#[instrument(skip(client))]
pub async fn messages(
client: &impl GenericClient,
chat: Uuid,
@ -185,6 +192,7 @@ impl Chat {
Ok(Pagination::new(result, total, pagination))
}
#[instrument(skip(client, text, extra))]
pub async fn send(
client: &mut impl GenericClient,
chat: Uuid,