Skip to content

Commit

Permalink
Update EF interop metrics
Browse files Browse the repository at this point in the history
- Remove `beacon_slot`, use previously unused `beacon_head_slot`
- Make metric setter names reflect actual metric names
- Add comment about extra EF interop metrics
- Add `beacon_previous_justified_epoch` metric
  • Loading branch information
Tumas committed Oct 7, 2024
1 parent e6e3e12 commit 434f1c1
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 46 deletions.
14 changes: 9 additions & 5 deletions fork_choice_control/src/mutator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1636,8 +1636,12 @@ where
P2pMessage::FinalizedCheckpoint(finalized_checkpoint).send(&self.p2p_tx);

if let Some(metrics) = self.metrics.as_ref() {
metrics.set_justified_epoch(justified_checkpoint.epoch);
metrics.set_finalized_epoch(finalized_checkpoint.epoch);
let state = head.state(&self.store);
let previous_justified_checkpoint = state.previous_justified_checkpoint();

metrics.set_beacon_current_justified_epoch(justified_checkpoint.epoch);
metrics.set_beacon_finalized_epoch(finalized_checkpoint.epoch);
metrics.set_beacon_previous_justified_epoch(previous_justified_checkpoint.epoch);
}

ValidatorMessage::FinalizedEth1Data(
Expand Down Expand Up @@ -2311,15 +2315,15 @@ where
}

fn track_epoch_transition_metrics(head_state: &Arc<BeaconState<P>>, metrics: &Arc<Metrics>) {
metrics.set_processed_deposits(head_state.eth1_deposit_index());
metrics.set_beacon_processed_deposits_total(head_state.eth1_deposit_index());
metrics.set_validator_count(head_state.validators().len_usize());
metrics.set_active_validators(
metrics.set_beacon_current_active_validators(
accessors::get_active_validator_indices(head_state, RelativeEpoch::Current).count(),
);
}

fn track_head_metrics(head: &ChainLink<P>, metrics: &Arc<Metrics>) {
metrics.set_slot(head.slot());
metrics.set_beacon_head_slot(head.slot());
}

fn track_collection_metrics(&self) {
Expand Down
85 changes: 44 additions & 41 deletions prometheus_metrics/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,17 @@ pub struct Metrics {
pub process_slot_times: Histogram,

// EF interop metrics
beacon_current_active_validators: IntGauge,
beacon_current_justified_epoch: IntGauge,
beacon_head_slot: IntGauge,
beacon_finalized_epoch: IntGauge,
beacon_safe_head_slot: IntGauge,
beacon_slot: IntGauge,
beacon_processed_deposits_total: IntGauge,
beacon_current_justified_epoch: IntGauge,
beacon_previous_justified_epoch: IntGauge,
beacon_current_active_validators: IntGauge,

pub beacon_reorgs_total: IntCounter,

beacon_processed_deposits_total: IntGauge,

// Extra EF interop metrics: not available in the docs yet
beacon_participation_prev_epoch_active_gwei_total: IntGauge,
beacon_participation_prev_epoch_target_attesting_gwei_total: IntGauge,
validator_count: IntGauge,
Expand Down Expand Up @@ -584,41 +586,42 @@ impl Metrics {
))?,

// EF interop metrics
beacon_current_active_validators: IntGauge::new(
"beacon_current_active_validators",
"Number of active validators",
)?,

beacon_current_justified_epoch: IntGauge::new(
"beacon_current_justified_epoch",
"Justified epoch at head",
beacon_head_slot: IntGauge::new(
"beacon_head_slot",
"Latest slot of the beacon chain",
)?,

beacon_finalized_epoch: IntGauge::new(
"beacon_finalized_epoch",
"Finalized epoch at head",
"Current finalized epoch",
)?,

beacon_safe_head_slot: IntGauge::new(
"beacon_head_slot",
"Head slot",
beacon_current_justified_epoch: IntGauge::new(
"beacon_current_justified_epoch",
"Current justified epoch",
)?,

beacon_slot: IntGauge::new(
"beacon_slot",
"Slot at the latest beacon head",
beacon_previous_justified_epoch: IntGauge::new(
"beacon_previous_justified_epoch",
"Current previously justified epoch",
)?,

beacon_processed_deposits_total: IntGauge::new(
"beacon_processed_deposits_total",
"Number of processed Eth1 deposits at head",
beacon_current_active_validators: IntGauge::new(
"beacon_current_active_validators",
"Current total active validators",
)?,

beacon_reorgs_total: IntCounter::new(
"beacon_reorgs_total",
"Total number of reorgs",
"Total number of chain reorganizations",
)?,

beacon_processed_deposits_total: IntGauge::new(
"beacon_processed_deposits_total",
"Total number of deposits processed",
)?,

// Extra EF interop metrics
beacon_participation_prev_epoch_active_gwei_total: IntGauge::new(
"beacon_participation_prev_epoch_active_gwei_total",
"Total effective balance of previous epoch active validators",
Expand Down Expand Up @@ -831,13 +834,13 @@ impl Metrics {
default_registry.register(Box::new(self.block_transition_times.clone()))?;
default_registry.register(Box::new(self.epoch_processing_times.clone()))?;
default_registry.register(Box::new(self.process_slot_times.clone()))?;
default_registry.register(Box::new(self.beacon_current_active_validators.clone()))?;
default_registry.register(Box::new(self.beacon_current_justified_epoch.clone()))?;
default_registry.register(Box::new(self.beacon_head_slot.clone()))?;
default_registry.register(Box::new(self.beacon_finalized_epoch.clone()))?;
default_registry.register(Box::new(self.beacon_safe_head_slot.clone()))?;
default_registry.register(Box::new(self.beacon_slot.clone()))?;
default_registry.register(Box::new(self.beacon_processed_deposits_total.clone()))?;
default_registry.register(Box::new(self.beacon_current_justified_epoch.clone()))?;
default_registry.register(Box::new(self.beacon_previous_justified_epoch.clone()))?;
default_registry.register(Box::new(self.beacon_current_active_validators.clone()))?;
default_registry.register(Box::new(self.beacon_reorgs_total.clone()))?;
default_registry.register(Box::new(self.beacon_processed_deposits_total.clone()))?;
default_registry.register(Box::new(
self.beacon_participation_prev_epoch_active_gwei_total
.clone(),
Expand Down Expand Up @@ -1021,28 +1024,28 @@ impl Metrics {
}

// EF interop metrics
pub fn set_active_validators(&self, validator_count: usize) {
self.beacon_current_active_validators
.set(validator_count as i64);
pub fn set_beacon_head_slot(&self, slot: Slot) {
self.beacon_head_slot.set(slot as i64);
}

pub fn set_justified_epoch(&self, epoch: Epoch) {
self.beacon_current_justified_epoch.set(epoch as i64);
pub fn set_beacon_finalized_epoch(&self, epoch: Epoch) {
self.beacon_finalized_epoch.set(epoch as i64);
}

pub fn set_finalized_epoch(&self, epoch: Epoch) {
self.beacon_finalized_epoch.set(epoch as i64);
pub fn set_beacon_current_justified_epoch(&self, epoch: Epoch) {
self.beacon_current_justified_epoch.set(epoch as i64);
}

pub fn set_safe_head_slot(&self, slot: Slot) {
self.beacon_safe_head_slot.set(slot as i64);
pub fn set_beacon_previous_justified_epoch(&self, epoch: Epoch) {
self.beacon_previous_justified_epoch.set(epoch as i64);
}

pub fn set_slot(&self, slot: Slot) {
self.beacon_slot.set(slot as i64);
pub fn set_beacon_current_active_validators(&self, validator_count: usize) {
self.beacon_current_active_validators
.set(validator_count as i64);
}

pub fn set_processed_deposits(&self, total_deposits: u64) {
pub fn set_beacon_processed_deposits_total(&self, total_deposits: u64) {
self.beacon_processed_deposits_total
.set(total_deposits as i64);
}
Expand Down

0 comments on commit 434f1c1

Please sign in to comment.