Add op pool metrics for attestations (#2758)

## Proposed Changes

Add several metrics for the number of attestations in the op pool. These give us a way to observe the number of valid, non-trivial attestations during block packing rather than just the size of the entire op pool.
This commit is contained in:
Michael Sproul
2021-11-01 05:52:31 +00:00
parent e8a557fdd8
commit ffb04e1a9e
4 changed files with 100 additions and 25 deletions

View File

@@ -365,6 +365,10 @@ lazy_static! {
*/
pub static ref OP_POOL_NUM_ATTESTATIONS: Result<IntGauge> =
try_create_int_gauge("beacon_op_pool_attestations_total", "Count of attestations in the op pool");
pub static ref OP_POOL_NUM_ATTESTATION_DATA: Result<IntGauge> =
try_create_int_gauge("beacon_op_pool_attestation_data_total", "Count of attestation data in the op pool");
pub static ref OP_POOL_MAX_AGGREGATES_PER_DATA: Result<IntGauge> =
try_create_int_gauge("beacon_op_pool_max_aggregates_per_data", "Max aggregates per AttestationData");
pub static ref OP_POOL_NUM_ATTESTER_SLASHINGS: Result<IntGauge> =
try_create_int_gauge("beacon_op_pool_attester_slashings_total", "Count of attester slashings in the op pool");
pub static ref OP_POOL_NUM_PROPOSER_SLASHINGS: Result<IntGauge> =
@@ -886,9 +890,19 @@ pub fn scrape_for_metrics<T: BeaconChainTypes>(beacon_chain: &BeaconChain<T>) {
scrape_sync_committee_observation(slot, beacon_chain);
}
let attestation_stats = beacon_chain.op_pool.attestation_stats();
set_gauge_by_usize(
&OP_POOL_NUM_ATTESTATIONS,
beacon_chain.op_pool.num_attestations(),
attestation_stats.num_attestations,
);
set_gauge_by_usize(
&OP_POOL_NUM_ATTESTATION_DATA,
attestation_stats.num_attestation_data,
);
set_gauge_by_usize(
&OP_POOL_MAX_AGGREGATES_PER_DATA,
attestation_stats.max_aggregates_per_data,
);
set_gauge_by_usize(
&OP_POOL_NUM_ATTESTER_SLASHINGS,