mirror of
https://github.com/sigp/lighthouse.git
synced 2026-06-30 03:14:25 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user