diff --git a/src/storage/mod.rs b/src/storage/mod.rs index 0d6ccc3b4..4dc418a52 100644 --- a/src/storage/mod.rs +++ b/src/storage/mod.rs @@ -25,7 +25,7 @@ use std::{ sync::Arc, }; use tokio::{io::AsyncWriteExt, runtime::Runtime}; -use tracing::{error, instrument, trace}; +use tracing::{error, info_span, instrument, trace, Instrument}; type FileRange = RangeInclusive; @@ -347,6 +347,7 @@ impl AsyncStorage { Ok(local_index_path) } + #[instrument(skip(fetch_time))] pub(crate) async fn get_from_archive( &self, archive_path: &str, @@ -360,10 +361,14 @@ impl AsyncStorage { } let index_filename = self .download_archive_index(archive_path, latest_build_id) + .instrument(info_span!("download archive index")) .await?; + let info = { let path = path.to_owned(); - spawn_blocking(move || archive_index::find_in_file(index_filename, &path)).await + spawn_blocking(move || archive_index::find_in_file(index_filename, &path)) + .instrument(info_span!("find path in index")) + .await }? .ok_or(PathNotFoundError)?; diff --git a/src/utils/mod.rs b/src/utils/mod.rs index e2e4131e8..b6fc8c926 100644 --- a/src/utils/mod.rs +++ b/src/utils/mod.rs @@ -28,11 +28,10 @@ use postgres::Client; use serde::de::DeserializeOwned; use serde::Serialize; use std::panic; -use tracing::error; +use tracing::{error, warn, Span}; pub(crate) mod sized_buffer; use std::{future::Future, thread, time::Duration}; -use tracing::warn; pub(crate) const APP_USER_AGENT: &str = concat!( env!("CARGO_PKG_NAME"), @@ -116,7 +115,15 @@ where F: FnOnce() -> Result + Send + 'static, R: Send + 'static, { - match tokio::task::spawn_blocking(f).await { + let span = Span::current(); + + let result = tokio::task::spawn_blocking(move || { + let _guard = span.enter(); + f() + }) + .await; + + match result { Ok(result) => result, Err(err) if err.is_panic() => panic::resume_unwind(err.into_panic()), Err(err) => Err(err.into()),