diff --git a/Cargo.lock b/Cargo.lock index 291fd1d5a..80e6cbab2 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,6 +1779,7 @@ dependencies = [ "lemmy_utils", "serde", "serde_json", + "tracing", "url", ] diff --git a/crates/api_common/Cargo.toml b/crates/api_common/Cargo.toml index 078987eb2..553ccb5bc 100644 --- a/crates/api_common/Cargo.toml +++ b/crates/api_common/Cargo.toml @@ -23,4 +23,5 @@ diesel = "1.4.8" actix-web = { version = "4.0.0-beta.9", default-features = false, features = ["cookies"] } chrono = { version = "0.4.19", features = ["serde"] } serde_json = { version = "1.0.68", features = ["preserve_order"] } +tracing = "0.1.29" url = "2.2.2" diff --git a/crates/api_common/src/lib.rs b/crates/api_common/src/lib.rs index 384f8ca7d..aa833a16c 100644 --- a/crates/api_common/src/lib.rs +++ b/crates/api_common/src/lib.rs @@ -32,9 +32,12 @@ where T: Send + 'static, { let pool = pool.clone(); + let blocking_span = tracing::info_span!("blocking operation"); let res = actix_web::web::block(move || { + let entered = blocking_span.enter(); let conn = pool.get()?; let res = (f)(&conn); + drop(entered); Ok(res) as Result }) .await?;