Automatically pass spans into blocking handles (#8158)

Co-Authored-By: Eitan Seri- Levi <eserilev@gmail.com>

Co-Authored-By: Eitan Seri-Levi <eserilev@ucsc.edu>

Co-Authored-By: Jimmy Chen <jchen.tc@gmail.com>
This commit is contained in:
Eitan Seri-Levi
2026-04-01 11:13:20 +09:00
committed by GitHub
parent 03385d698d
commit 99f5a92b98
9 changed files with 29 additions and 82 deletions

View File

@@ -58,7 +58,6 @@ use store::{
Error as StoreError, KeyValueStore, KeyValueStoreOp, StoreConfig, iter::StateRootsIterator,
};
use task_executor::{JoinHandle, ShutdownReason};
use tracing::info_span;
use tracing::{debug, error, info, instrument, warn};
use types::*;
@@ -528,22 +527,15 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
/// such a case it's critical that the `BeaconChain` keeps importing blocks so that the
/// situation can be rectified. We avoid returning an error here so that calling functions
/// can't abort block import because an error is returned here.
#[instrument(name = "lh_recompute_head_at_slot", skip(self), level = "info", fields(slot = %current_slot))]
pub async fn recompute_head_at_slot(self: &Arc<Self>, current_slot: Slot) {
let span = info_span!(
"lh_recompute_head_at_slot",
slot = %current_slot
);
metrics::inc_counter(&metrics::FORK_CHOICE_REQUESTS);
let _timer = metrics::start_timer(&metrics::FORK_CHOICE_TIMES);
let chain = self.clone();
match self
.spawn_blocking_handle(
move || {
let _guard = span.enter();
chain.recompute_head_at_slot_internal(current_slot)
},
move || chain.recompute_head_at_slot_internal(current_slot),
"recompute_head_internal",
)
.await