Skip to content

Commit

Permalink
Log error when exposing metrics fails
Browse files Browse the repository at this point in the history
  • Loading branch information
paulhauner committed Jul 15, 2021
1 parent 4533190 commit b9d8e07
Showing 1 changed file with 32 additions and 15 deletions.
47 changes: 32 additions & 15 deletions beacon_node/beacon_chain/src/block_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,7 @@ impl<'a, T: BeaconChainTypes> FullyVerifiedBlock<'a, T> {
}
}

expose_participation_metrics(&summaries);
expose_participation_metrics(&summaries, &chain.log);

// If the block is sufficiently recent, notify the validator monitor.
if let Some(slot) = chain.slot_clock.now() {
Expand Down Expand Up @@ -1440,27 +1440,44 @@ fn verify_header_signature<T: BeaconChainTypes>(
}
}

fn expose_participation_metrics(summaries: &[EpochProcessingSummary]) {
fn expose_participation_metrics(summaries: &[EpochProcessingSummary], log: &Logger) {
if !cfg!(feature = "participation_metrics") {
return;
}

for summary in summaries {
if let Ok(target_balance) = summary.previous_epoch_target_attesting_balance() {
metrics::maybe_set_float_gauge(
&metrics::PARTICIPATION_PREV_EPOCH_TARGET_ATTESTER,
participation_ratio(
target_balance,
summary.previous_epoch_total_active_balance(),
),
);
match summary.previous_epoch_target_attesting_balance() {
Ok(target_balance) => {
metrics::maybe_set_float_gauge(
&metrics::PARTICIPATION_PREV_EPOCH_TARGET_ATTESTER,
participation_ratio(
target_balance,
summary.previous_epoch_total_active_balance(),
),
);
}
Err(e) => error!(
log,
"Unable to read target balance";
"error" => ?e,
),
}

if let Ok(head_balance) = summary.previous_epoch_head_attesting_balance() {
metrics::maybe_set_float_gauge(
&metrics::PARTICIPATION_PREV_EPOCH_HEAD_ATTESTER,
participation_ratio(head_balance, summary.previous_epoch_total_active_balance()),
);
match summary.previous_epoch_head_attesting_balance() {
Ok(head_balance) => {
metrics::maybe_set_float_gauge(
&metrics::PARTICIPATION_PREV_EPOCH_HEAD_ATTESTER,
participation_ratio(
head_balance,
summary.previous_epoch_total_active_balance(),
),
);
}
Err(e) => error!(
log,
"Unable to read head balance";
"error" => ?e,
),
}
}
}
Expand Down

0 comments on commit b9d8e07

Please sign in to comment.