From 0222985f4d2cc72132b2f3ac74cfc1573265ccb7 Mon Sep 17 00:00:00 2001 From: Bill Thiede Date: Mon, 16 Dec 2024 08:56:05 -0800 Subject: [PATCH] server: instrument newsreader impl --- server/src/newsreader.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/server/src/newsreader.rs b/server/src/newsreader.rs index 84e69c0..92a7b70 100644 --- a/server/src/newsreader.rs +++ b/server/src/newsreader.rs @@ -7,6 +7,7 @@ use scraper::Selector; use shared::compute_color; use sqlx::postgres::PgPool; use tokio::sync::Mutex; +use tracing::instrument; use url::Url; use crate::{ @@ -52,6 +53,7 @@ fn site_from_tags(tags: &[String]) -> Option { None } +#[instrument(name = "newsreader::count", skip_all, fields(query=%query))] pub async fn count(pool: &PgPool, query: &Query) -> Result { if !is_newsreader_query(query) { return Ok(0); @@ -75,6 +77,7 @@ pub async fn count(pool: &PgPool, query: &Query) -> Result { Ok(row.count.unwrap_or(0).try_into().unwrap_or(0)) } +#[instrument(name = "newsreader::search", skip_all, fields(query=%query))] pub async fn search( pool: &PgPool, after: Option, @@ -141,6 +144,7 @@ pub async fn search( } Ok(res) } +#[instrument(name = "newsreader::tags", skip_all, fields(needs_unread=%_needs_unread))] pub async fn tags(pool: &PgPool, _needs_unread: bool) -> Result, ServerError> { // TODO: optimize query by using needs_unread let tags = sqlx::query_file!("sql/tags.sql").fetch_all(pool).await?; @@ -164,6 +168,7 @@ pub async fn tags(pool: &PgPool, _needs_unread: bool) -> Result, Server Ok(tags) } +#[instrument(name = "newsreader::thread", skip_all, fields(thread_id=%thread_id))] pub async fn thread( config: &Config, pool: &PgPool, @@ -280,6 +285,7 @@ pub async fn thread( timestamp, })) } +#[instrument(name = "newsreader::set_read_status", skip_all, fields(query=%query,unread=%unread))] pub async fn set_read_status<'ctx>( pool: &PgPool, query: &Query,