Skip to content

Commit d50fc3f

Browse files
authored
refactor: improve tracing of blob cache by passing span to task (#32)
1 parent 8c5dde4 commit d50fc3f

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

crates/blobber/src/cache.rs

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use std::{
1313
time::Duration,
1414
};
1515
use tokio::sync::{mpsc, oneshot};
16-
use tracing::{error, info, instrument, warn};
16+
use tracing::{Instrument, debug, error, info, instrument};
1717

1818
const BLOB_CACHE_SIZE: u32 = (MAX_BLOBS_PER_BLOCK_ELECTRA * EPOCH_SLOTS) as u32;
1919
const CACHE_REQUEST_CHANNEL_SIZE: usize = (MAX_BLOBS_PER_BLOCK_ELECTRA * 2) as usize;
@@ -26,7 +26,13 @@ const BETWEEN_RETRIES: Duration = Duration::from_millis(250);
2626
/// retrieving blobs.
2727
#[derive(Debug)]
2828
enum CacheInst {
29-
Retrieve { slot: usize, tx_hash: B256, version_hashes: Vec<B256>, resp: oneshot::Sender<Blobs> },
29+
Retrieve {
30+
slot: usize,
31+
tx_hash: B256,
32+
version_hashes: Vec<B256>,
33+
resp: oneshot::Sender<Blobs>,
34+
span: tracing::Span,
35+
},
3036
}
3137

3238
/// Handle for the cache.
@@ -51,7 +57,14 @@ impl CacheHandle {
5157
) -> FetchResult<Blobs> {
5258
let (resp, receiver) = oneshot::channel();
5359

54-
self.send(CacheInst::Retrieve { slot, tx_hash, version_hashes, resp }).await;
60+
self.send(CacheInst::Retrieve {
61+
slot,
62+
tx_hash,
63+
version_hashes,
64+
resp,
65+
span: tracing::Span::current(),
66+
})
67+
.await;
5568

5669
receiver.await.map_err(|_| BlobFetcherError::missing_sidecar(tx_hash))
5770
}
@@ -164,7 +177,7 @@ impl<Pool: TransactionPool + 'static> BlobCacher<Pool> {
164177
return Ok(blobs);
165178
}
166179
Err(BlobFetcherError::Ignorable(e)) => {
167-
warn!(target: "signet_blobber::BlobCacher", attempt, %e, "Blob fetch attempt failed.");
180+
debug!(target: "signet_blobber::BlobCacher", attempt, %e, "Blob fetch attempt failed.");
168181
tokio::time::sleep(BETWEEN_RETRIES).await;
169182
continue;
170183
}
@@ -178,8 +191,10 @@ impl<Pool: TransactionPool + 'static> BlobCacher<Pool> {
178191
/// Processes the cache instructions.
179192
async fn handle_inst(self: Arc<Self>, inst: CacheInst) {
180193
match inst {
181-
CacheInst::Retrieve { slot, tx_hash, version_hashes, resp } => {
182-
if let Ok(blobs) = self.fetch_blobs(slot, tx_hash, version_hashes).await {
194+
CacheInst::Retrieve { slot, tx_hash, version_hashes, resp, span } => {
195+
if let Ok(blobs) =
196+
self.fetch_blobs(slot, tx_hash, version_hashes).instrument(span).await
197+
{
183198
// if listener has gone away, that's okay, we just won't send the response
184199
let _ = resp.send(blobs);
185200
}

crates/blobber/src/fetch.rs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use signet_extract::{ExtractedEvent, Extracts};
1616
use signet_zenith::{Zenith::BlockSubmitted, ZenithBlock};
1717
use std::{ops::Deref, sync::Arc};
1818
use tokio::select;
19-
use tracing::{error, instrument, trace};
19+
use tracing::{instrument, trace};
2020

2121
/// Blobs which may be a local shared sidecar, or a list of blobs from an
2222
/// external source.
@@ -161,7 +161,7 @@ where
161161
}
162162

163163
/// Fetch blobs from the local txpool, or fall back to remote sources
164-
#[instrument(skip(self, versioned_hashes))]
164+
#[instrument(skip(self))]
165165
pub(crate) async fn fetch_blobs(
166166
&self,
167167
slot: usize,
@@ -185,7 +185,6 @@ where
185185
Ok(blobs)
186186
}
187187
else => {
188-
error!(%tx_hash, "Blobs not available from any source");
189188
Err(BlobFetcherError::missing_sidecar(tx_hash))
190189
}
191190
}

0 commit comments

Comments
 (0)