Skip to content

Commit 3699918

Browse files
authored
feat(scraper): Add span to cursor indexer task (#7232)
Co-authored-by: Danil Nemirovsky <[email protected]>
1 parent 8fc8325 commit 3699918

File tree

1 file changed

+22
-15
lines changed
  • rust/main/hyperlane-base/src/contract_sync

1 file changed

+22
-15
lines changed

rust/main/hyperlane-base/src/contract_sync/mod.rs

Lines changed: 22 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use eyre::Result;
1111
use prometheus::core::{AtomicI64, AtomicU64, GenericCounter, GenericGauge};
1212
use tokio::sync::{mpsc::Receiver as MpscReceiver, Mutex};
1313
use tokio::time::sleep;
14-
use tracing::{debug, info, instrument, trace, warn};
14+
use tracing::{debug, info, instrument, trace, warn, Instrument};
1515

1616
use hyperlane_core::{
1717
utils::fmt_sync_time, ContractSyncCursor, CursorAction, HyperlaneDomain, HyperlaneLogStore,
@@ -97,7 +97,7 @@ where
9797
}
9898

9999
/// Sync logs and write them to the LogStore
100-
#[instrument(name = "ContractSync", fields(domain=self.domain().name()), skip(self, opts))]
100+
#[instrument(name = "ContractSync", fields(domain=self.domain().name(), label), skip(self, opts))]
101101
pub async fn sync(&self, label: &'static str, opts: SyncOptions<T>) {
102102
let chain_name = self.domain.as_ref();
103103
let indexed_height_metric = self
@@ -155,19 +155,26 @@ where
155155

156156
let stored_logs_metric = stored_logs_metric.clone();
157157

158-
tokio::task::spawn(async {
159-
Self::cursor_indexer_task(
160-
domain_clone,
161-
indexer_clone,
162-
store_clone,
163-
cursor,
164-
broadcast_sender,
165-
stored_logs_metric,
166-
indexed_height_metric,
167-
liveness_metric,
168-
)
169-
.await;
170-
})
158+
tokio::task::spawn(
159+
async {
160+
Self::cursor_indexer_task(
161+
domain_clone,
162+
indexer_clone,
163+
store_clone,
164+
cursor,
165+
broadcast_sender,
166+
stored_logs_metric,
167+
indexed_height_metric,
168+
liveness_metric,
169+
)
170+
.await
171+
}
172+
.instrument(tracing::info_span!(
173+
"spawn_cursor_indexer_task",
174+
domain = self.domain().name(),
175+
label
176+
)),
177+
)
171178
}
172179
None => tokio::task::spawn(async {}),
173180
};

0 commit comments

Comments
 (0)