pub fn scrape_metrics<S: SlotClock>(&self, slot_clock: &S, spec: &ChainSpec) {
        metrics::set_gauge(
            &metrics::VALIDATOR_MONITOR_VALIDATORS_TOTAL,
            self.num_validators() as i64,
        );

        if let Some(slot) = slot_clock.now() {
            let epoch = slot.epoch(T::slots_per_epoch());
            let slot_in_epoch = slot % T::slots_per_epoch();

            // Only start to report on the current epoch once we've progressed past the point where
            // all attestation should be included in a block.
            //
            // This allows us to set alarms on Grafana to detect when an attestation has been
            // missed. If we didn't delay beyond the attestation inclusion period then we could
            // expect some occasional false-positives on attestation misses.
            //
            // I have chosen 3 as an arbitrary number where we *probably* shouldn't see that many
            // skip slots on mainnet.
            let previous_epoch = if slot_in_epoch > spec.min_attestation_inclusion_delay + 3 {
                epoch - 1
            } else {
                epoch - 2
            };

            for (_, validator) in self.validators.iter() {
                let id = &validator.id;
                let summaries = validator.summaries.read();

                if let Some(summary) = summaries.get(&previous_epoch) {
                    /*
                     * Attestations
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_TOTAL,
                        &[id],
                        summary.attestations as i64,
                    );
                    if let Some(delay) = summary.attestation_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_AGGREGATE_INCLUSIONS,
                        &[id],
                        summary.attestation_aggregate_incusions as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_INCLUSIONS,
                        &[id],
                        summary.attestation_block_inclusions as i64,
                    );
                    if let Some(distance) = summary.attestation_min_block_inclusion_distance {
                        metrics::set_gauge_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_MIN_INCLUSION_DISTANCE,
                            &[id],
                            distance.as_u64() as i64,
                        );
                    }
                    /*
                     * Blocks
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_TOTAL,
                        &[id],
                        summary.blocks as i64,
                    );
                    if let Some(delay) = summary.block_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    /*
                     * Aggregates
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_TOTAL,
                        &[id],
                        summary.aggregates as i64,
                    );
                    if let Some(delay) = summary.aggregate_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    /*
                     * Other
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_EXITS_TOTAL,
                        &[id],
                        summary.exits as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_PROPOSER_SLASHINGS_TOTAL,
                        &[id],
                        summary.proposer_slashings as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTER_SLASHINGS_TOTAL,
                        &[id],
                        summary.attester_slashings as i64,
                    );
                }
            }
        }
    }
/// Scrape `self` for metrics.
///
/// Should be called whenever Prometheus is scraping Lighthouse.
Scrape `self` for metrics.
Should be called whenever Prometheus is scraping Lighthouse.
Scrape ` self ` for metrics . Should be called whenever Prometheus is scraping Lighthouse .
pub fn scrape_metrics<S: SlotClock>(&self, slot_clock: &S, spec: &ChainSpec) {
        metrics::set_gauge(
            &metrics::VALIDATOR_MONITOR_VALIDATORS_TOTAL,
            self.num_validators() as i64,
        );
        if let Some(slot) = slot_clock.now() {
            let epoch = slot.epoch(T::slots_per_epoch());
            let slot_in_epoch = slot % T::slots_per_epoch();
            // Only start to report on the current epoch once we've progressed past the point where
            // all attestation should be included in a block.
            //
            // This allows us to set alarms on Grafana to detect when an attestation has been
            // missed. If we didn't delay beyond the attestation inclusion period then we could
            // expect some occasional false-positives on attestation misses.
            //
            // I have chosen 3 as an arbitrary number where we *probably* shouldn't see that many
            // skip slots on mainnet.
            let previous_epoch = if slot_in_epoch > spec.min_attestation_inclusion_delay + 3 {
                epoch - 1
            } else {
                epoch - 2
            };
            for (_, validator) in self.validators.iter() {
                let id = &validator.id;
                let summaries = validator.summaries.read();
                if let Some(summary) = summaries.get(&previous_epoch) {
                    /*
                     * Attestations
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_TOTAL,
                        &[id],
                        summary.attestations as i64,
                    );
                    if let Some(delay) = summary.attestation_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_AGGREGATE_INCLUSIONS,
                        &[id],
                        summary.attestation_aggregate_incusions as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_INCLUSIONS,
                        &[id],
                        summary.attestation_block_inclusions as i64,
                    );
                    if let Some(distance) = summary.attestation_min_block_inclusion_distance {
                        metrics::set_gauge_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_MIN_INCLUSION_DISTANCE,
                            &[id],
                            distance.as_u64() as i64,
                        );
                    }
                    /*
                     * Blocks
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_TOTAL,
                        &[id],
                        summary.blocks as i64,
                    );
                    if let Some(delay) = summary.block_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    /*
                     * Aggregates
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_TOTAL,
                        &[id],
                        summary.aggregates as i64,
                    );
                    if let Some(delay) = summary.aggregate_min_delay {
                        metrics::observe_timer_vec(
                            &metrics::VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_MIN_DELAY_SECONDS,
                            &[id],
                            delay,
                        );
                    }
                    /*
                     * Other
                     */
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_EXITS_TOTAL,
                        &[id],
                        summary.exits as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_PROPOSER_SLASHINGS_TOTAL,
                        &[id],
                        summary.proposer_slashings as i64,
                    );
                    metrics::set_gauge_vec(
                        &metrics::VALIDATOR_MONITOR_PREV_EPOCH_ATTESTER_SLASHINGS_TOTAL,
                        &[id],
                        summary.attester_slashings as i64,
                    );
                }
            }
        }
    }
pub fn scrape_metrics < S : SlotClock > ( & self , slot_clock : & S , spec : & ChainSpec ) { metrics :: set_gauge ( & metrics :: VALIDATOR_MONITOR_VALIDATORS_TOTAL , self . num_validators ( ) as i64 , ) ; if let Some ( slot ) = slot_clock . now ( ) { let epoch = slot . epoch ( T :: slots_per_epoch ( ) ) ; let slot_in_epoch = slot % T :: slots_per_epoch ( ) ; // Only start to report on the current epoch once we've progressed past the point where // all attestation should be included in a block. // // This allows us to set alarms on Grafana to detect when an attestation has been // missed. If we didn't delay beyond the attestation inclusion period then we could // expect some occasional false-positives on attestation misses. // // I have chosen 3 as an arbitrary number where we *probably* shouldn't see that many // skip slots on mainnet. let previous_epoch = if slot_in_epoch > spec . min_attestation_inclusion_delay + 3 { epoch - 1 } else { epoch - 2 } ; for ( _ , validator ) in self . validators . iter ( ) { let id = & validator . id ; let summaries = validator . summaries . read ( ) ; if let Some ( summary ) = summaries . get ( & previous_epoch ) { /*
                     * Attestations
                     */ metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_TOTAL , & [ id ] , summary . attestations as i64 , ) ; if let Some ( delay ) = summary . attestation_min_delay { metrics :: observe_timer_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATIONS_MIN_DELAY_SECONDS , & [ id ] , delay , ) ; } metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_AGGREGATE_INCLUSIONS , & [ id ] , summary . attestation_aggregate_incusions as i64 , ) ; metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_INCLUSIONS , & [ id ] , summary . attestation_block_inclusions as i64 , ) ; if let Some ( distance ) = summary . attestation_min_block_inclusion_distance { metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTATION_BLOCK_MIN_INCLUSION_DISTANCE , & [ id ] , distance . as_u64 ( ) as i64 , ) ; } /*
                     * Blocks
                     */ metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_TOTAL , & [ id ] , summary . blocks as i64 , ) ; if let Some ( delay ) = summary . block_min_delay { metrics :: observe_timer_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_BEACON_BLOCKS_MIN_DELAY_SECONDS , & [ id ] , delay , ) ; } /*
                     * Aggregates
                     */ metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_TOTAL , & [ id ] , summary . aggregates as i64 , ) ; if let Some ( delay ) = summary . aggregate_min_delay { metrics :: observe_timer_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_AGGREGATES_MIN_DELAY_SECONDS , & [ id ] , delay , ) ; } /*
                     * Other
                     */ metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_EXITS_TOTAL , & [ id ] , summary . exits as i64 , ) ; metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_PROPOSER_SLASHINGS_TOTAL , & [ id ] , summary . proposer_slashings as i64 , ) ; metrics :: set_gauge_vec ( & metrics :: VALIDATOR_MONITOR_PREV_EPOCH_ATTESTER_SLASHINGS_TOTAL , & [ id ] , summary . attester_slashings as i64 , ) ; } } } }
Scrape `self` for metrics.
Scrape ` self ` for metrics .
&self
slot_clock
&S
spec
&ChainSpec