Skip to content

Commit 60738ee

Browse files
committed
add more tracing to storare APIs, pass span into spawn_blocking
1 parent 045ae1c commit 60738ee

File tree

2 files changed

+17
-5
lines changed

2 files changed

+17
-5
lines changed

src/storage/mod.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use std::{
2525
sync::Arc,
2626
};
2727
use tokio::{io::AsyncWriteExt, runtime::Runtime};
28-
use tracing::{error, instrument, trace};
28+
use tracing::{error, info_span, instrument, trace, Instrument};
2929

3030
type FileRange = RangeInclusive<u64>;
3131

@@ -347,6 +347,7 @@ impl AsyncStorage {
347347
Ok(local_index_path)
348348
}
349349

350+
#[instrument(skip(fetch_time))]
350351
pub(crate) async fn get_from_archive(
351352
&self,
352353
archive_path: &str,
@@ -360,10 +361,14 @@ impl AsyncStorage {
360361
}
361362
let index_filename = self
362363
.download_archive_index(archive_path, latest_build_id)
364+
.instrument(info_span!("download archive index"))
363365
.await?;
366+
364367
let info = {
365368
let path = path.to_owned();
366-
spawn_blocking(move || archive_index::find_in_file(index_filename, &path)).await
369+
spawn_blocking(move || archive_index::find_in_file(index_filename, &path))
370+
.instrument(info_span!("find path in index"))
371+
.await
367372
}?
368373
.ok_or(PathNotFoundError)?;
369374

src/utils/mod.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@ use postgres::Client;
2828
use serde::de::DeserializeOwned;
2929
use serde::Serialize;
3030
use std::panic;
31-
use tracing::error;
31+
use tracing::{error, warn, Span};
3232
pub(crate) mod sized_buffer;
3333

3434
use std::{future::Future, thread, time::Duration};
35-
use tracing::warn;
3635

3736
pub(crate) const APP_USER_AGENT: &str = concat!(
3837
env!("CARGO_PKG_NAME"),
@@ -116,7 +115,15 @@ where
116115
F: FnOnce() -> Result<R> + Send + 'static,
117116
R: Send + 'static,
118117
{
119-
match tokio::task::spawn_blocking(f).await {
118+
let span = Span::current();
119+
120+
let result = tokio::task::spawn_blocking(move || {
121+
let _guard = span.enter();
122+
f()
123+
})
124+
.await;
125+
126+
match result {
120127
Ok(result) => result,
121128
Err(err) if err.is_panic() => panic::resume_unwind(err.into_panic()),
122129
Err(err) => Err(err.into()),

0 commit comments

Comments
 (0)