diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 29e26e1e6..9941bf786 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -45,6 +45,7 @@ where res } +#[tracing::instrument(skip_all)] pub async fn is_mod_or_admin( pool: &DbPool, person_id: PersonId, @@ -67,6 +68,7 @@ pub fn is_admin(local_user_view: &LocalUserView) -> Result<(), LemmyError> { Ok(()) } +#[tracing::instrument(skip_all)] pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result { blocking(pool, move |conn| Post::read(conn, post_id)) .await? @@ -74,6 +76,7 @@ pub async fn get_post(post_id: PostId, pool: &DbPool) -> Result>, pool: &DbPool, @@ -155,6 +161,7 @@ pub async fn get_local_user_view_from_jwt_opt( } } +#[tracing::instrument(skip_all)] pub async fn get_local_user_settings_view_from_jwt( jwt: &Sensitive, pool: &DbPool, @@ -179,6 +186,7 @@ pub async fn get_local_user_settings_view_from_jwt( Ok(local_user_view) } +#[tracing::instrument(skip_all)] pub async fn get_local_user_settings_view_from_jwt_opt( jwt: Option<&Sensitive>, pool: &DbPool, @@ -192,6 +200,7 @@ pub async fn get_local_user_settings_view_from_jwt_opt( } } +#[tracing::instrument(skip_all)] pub async fn check_community_ban( person_id: PersonId, community_id: CommunityId, @@ -206,6 +215,7 @@ pub async fn check_community_ban( } } +#[tracing::instrument(skip_all)] pub async fn check_community_deleted_or_removed( community_id: CommunityId, pool: &DbPool, @@ -229,6 +239,7 @@ pub fn check_post_deleted_or_removed(post: &Post) -> Result<(), LemmyError> { } } +#[tracing::instrument(skip_all)] pub async fn check_person_block( my_id: PersonId, potential_blocker_id: PersonId, @@ -242,6 +253,7 @@ pub async fn check_person_block( } } +#[tracing::instrument(skip_all)] pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), LemmyError> { if score == -1 { let site = blocking(pool, Site::read_simple).await??; @@ -252,6 +264,7 @@ pub async fn check_downvotes_enabled(score: i16, pool: &DbPool) -> Result<(), Le Ok(()) } +#[tracing::instrument(skip_all)] pub async fn build_federated_instances( pool: &DbPool, federation_config: &FederationConfig, diff --git a/crates/api_crud/src/post/create.rs b/crates/api_crud/src/post/create.rs index bc2f29f7f..276504be3 100644 --- a/crates/api_crud/src/post/create.rs +++ b/crates/api_crud/src/post/create.rs @@ -31,7 +31,7 @@ use lemmy_utils::{ LemmyError, }; use lemmy_websocket::{send::send_post_ws_message, LemmyContext, UserOperationCrud}; -use tracing::warn; +use tracing::{warn, Instrument}; use url::Url; use webmention::{Webmention, WebmentionError}; @@ -132,7 +132,11 @@ impl PerformCrud for CreatePost { let mut webmention = Webmention::new::(updated_post.ap_id.clone().into(), url.clone().into())?; webmention.set_checked(true); - match webmention.send().await { + match webmention + .send() + .instrument(tracing::info_span!("Sending webmention")) + .await + { Ok(_) => {} Err(WebmentionError::NoEndpointDiscovered(_)) => {} Err(e) => warn!("Failed to send webmention: {}", e), diff --git a/crates/utils/src/request.rs b/crates/utils/src/request.rs index 10341e801..83916cf68 100644 --- a/crates/utils/src/request.rs +++ b/crates/utils/src/request.rs @@ -17,6 +17,7 @@ struct SendError(pub String); #[error("Error receiving response, {0}")] pub struct RecvError(pub String); +#[tracing::instrument(skip_all)] pub async fn retry(f: F) -> Result where F: Fn() -> Fut, @@ -25,6 +26,7 @@ where retry_custom(|| async { Ok((f)().await) }).await } +#[tracing::instrument(skip_all)] async fn retry_custom(f: F) -> Result where F: Fn() -> Fut, @@ -60,6 +62,7 @@ pub struct SiteMetadata { } /// Fetches the post link html tags (like title, description, image, etc) +#[tracing::instrument(skip_all)] pub async fn fetch_site_metadata( client: &ClientWithMiddleware, url: &Url, @@ -124,6 +127,7 @@ pub(crate) struct PictrsFile { delete_token: String, } +#[tracing::instrument(skip_all)] pub(crate) async fn fetch_pictrs( client: &ClientWithMiddleware, settings: &Settings, @@ -157,6 +161,7 @@ pub(crate) async fn fetch_pictrs( /// Both are options, since the URL might be either an html page, or an image /// Returns the SiteMetadata, and a Pictrs URL, if there is a picture associated +#[tracing::instrument(skip_all)] pub async fn fetch_site_data( client: &ClientWithMiddleware, settings: &Settings, @@ -207,6 +212,7 @@ pub async fn fetch_site_data( } } +#[tracing::instrument(skip_all)] async fn is_image_content_type(client: &ClientWithMiddleware, url: &Url) -> Result<(), LemmyError> { let response = client.get(url.as_str()).send().await?; if response diff --git a/crates/websocket/src/send.rs b/crates/websocket/src/send.rs index ac0752c64..efe3a8552 100644 --- a/crates/websocket/src/send.rs +++ b/crates/websocket/src/send.rs @@ -37,6 +37,7 @@ use lemmy_utils::{ }; use tracing::error; +#[tracing::instrument(skip_all)] pub async fn send_post_ws_message( post_id: PostId, op: OP, @@ -62,6 +63,7 @@ pub async fn send_post_ws_message // TODO: in many call sites in apub crate, we are setting an empty vec for recipient_ids, // we should get the actual recipient actors from somewhere +#[tracing::instrument(skip_all)] pub async fn send_comment_ws_message_simple( comment_id: CommentId, op: OP, @@ -70,6 +72,7 @@ pub async fn send_comment_ws_message_simple( comment_id: CommentId, op: OP, @@ -108,6 +111,7 @@ pub async fn send_comment_ws_message( community_id: CommunityId, op: OP, @@ -136,6 +140,7 @@ pub async fn send_community_ws_message( private_message_id: PrivateMessageId, op: OP, @@ -174,6 +179,7 @@ pub async fn send_pm_ws_message( Ok(res) } +#[tracing::instrument(skip_all)] pub async fn send_local_notifs( mentions: Vec, comment: &Comment, @@ -297,6 +303,7 @@ pub async fn send_local_notifs( Ok(recipient_ids) } +#[tracing::instrument(skip_all)] pub fn send_email_to_user( local_user_view: &LocalUserView, subject_text: &str,