mirror of https://github.com/LemmyNet/lemmy.git
More instrument
parent
ea41e5531c
commit
4d1e9c640b
|
@ -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<Post, LemmyError> {
|
||||
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<Post, LemmyError
|
|||
.map_err(|e| e.with_message("couldnt_find_post"))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn mark_post_as_read(
|
||||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
|
@ -89,6 +92,7 @@ pub async fn mark_post_as_read(
|
|||
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn mark_post_as_unread(
|
||||
person_id: PersonId,
|
||||
post_id: PostId,
|
||||
|
@ -104,6 +108,7 @@ pub async fn mark_post_as_unread(
|
|||
.map_err(|e| e.with_message("couldnt_mark_post_as_read"))
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn get_local_user_view_from_jwt(
|
||||
jwt: &str,
|
||||
pool: &DbPool,
|
||||
|
@ -144,6 +149,7 @@ pub fn check_validator_time(
|
|||
}
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn get_local_user_view_from_jwt_opt(
|
||||
jwt: Option<&Sensitive<String>>,
|
||||
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<String>,
|
||||
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<String>>,
|
||||
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,
|
||||
|
|
|
@ -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::<Url>(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),
|
||||
|
|
|
@ -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, Fut, T>(f: F) -> Result<T, reqwest_middleware::Error>
|
||||
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, Fut, T>(f: F) -> Result<T, reqwest_middleware::Error>
|
||||
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
|
||||
|
|
|
@ -37,6 +37,7 @@ use lemmy_utils::{
|
|||
};
|
||||
use tracing::error;
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn send_post_ws_message<OP: ToString + Send + OperationType + 'static>(
|
||||
post_id: PostId,
|
||||
op: OP,
|
||||
|
@ -62,6 +63,7 @@ pub async fn send_post_ws_message<OP: ToString + Send + OperationType + 'static>
|
|||
|
||||
// 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<OP: ToString + Send + OperationType + 'static>(
|
||||
comment_id: CommentId,
|
||||
op: OP,
|
||||
|
@ -70,6 +72,7 @@ pub async fn send_comment_ws_message_simple<OP: ToString + Send + OperationType
|
|||
send_comment_ws_message(comment_id, op, None, None, None, vec![], context).await
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn send_comment_ws_message<OP: ToString + Send + OperationType + 'static>(
|
||||
comment_id: CommentId,
|
||||
op: OP,
|
||||
|
@ -108,6 +111,7 @@ pub async fn send_comment_ws_message<OP: ToString + Send + OperationType + 'stat
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn send_community_ws_message<OP: ToString + Send + OperationType + 'static>(
|
||||
community_id: CommunityId,
|
||||
op: OP,
|
||||
|
@ -136,6 +140,7 @@ pub async fn send_community_ws_message<OP: ToString + Send + OperationType + 'st
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn send_pm_ws_message<OP: ToString + Send + OperationType + 'static>(
|
||||
private_message_id: PrivateMessageId,
|
||||
op: OP,
|
||||
|
@ -174,6 +179,7 @@ pub async fn send_pm_ws_message<OP: ToString + Send + OperationType + 'static>(
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
#[tracing::instrument(skip_all)]
|
||||
pub async fn send_local_notifs(
|
||||
mentions: Vec<MentionData>,
|
||||
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,
|
||||
|
|
Loading…
Reference in New Issue