From c91345782a79d33408dc3c39698207a01116b99a Mon Sep 17 00:00:00 2001 From: Pawan Dhananjay Date: Tue, 13 Jan 2026 13:20:40 +0530 Subject: [PATCH] Get blobs v2 metrics (#8641) N/A Add standardized metrics for getBlobsV2 from https://github.com/ethereum/beacon-metrics/pull/14. Co-Authored-By: Pawan Dhananjay --- .../beacon_chain/src/fetch_blobs/mod.rs | 11 ++++++++ beacon_node/beacon_chain/src/metrics.rs | 27 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/beacon_node/beacon_chain/src/fetch_blobs/mod.rs b/beacon_node/beacon_chain/src/fetch_blobs/mod.rs index 4c6b2d10a9..3a1cf146ed 100644 --- a/beacon_node/beacon_chain/src/fetch_blobs/mod.rs +++ b/beacon_node/beacon_chain/src/fetch_blobs/mod.rs @@ -247,6 +247,12 @@ async fn fetch_and_process_blobs_v2( metrics::observe(&metrics::BLOBS_FROM_EL_EXPECTED, num_expected_blobs as f64); debug!(num_expected_blobs, "Fetching blobs from the EL"); + + // Track request count and duration for standardized metrics + inc_counter(&metrics::BEACON_ENGINE_GET_BLOBS_V2_REQUESTS_TOTAL); + let _timer = + metrics::start_timer(&metrics::BEACON_ENGINE_GET_BLOBS_V2_REQUEST_DURATION_SECONDS); + let response = chain_adapter .get_blobs_v2(versioned_hashes) .await @@ -254,6 +260,11 @@ async fn fetch_and_process_blobs_v2( inc_counter(&metrics::BLOBS_FROM_EL_ERROR_TOTAL); })?; + drop(_timer); + + // Track successful response + inc_counter(&metrics::BEACON_ENGINE_GET_BLOBS_V2_RESPONSES_TOTAL); + let Some(blobs_and_proofs) = response else { debug!(num_expected_blobs, "No blobs fetched from the EL"); inc_counter(&metrics::BLOBS_FROM_EL_MISS_TOTAL); diff --git a/beacon_node/beacon_chain/src/metrics.rs b/beacon_node/beacon_chain/src/metrics.rs index d6b76a6f94..6be07faa24 100644 --- a/beacon_node/beacon_chain/src/metrics.rs +++ b/beacon_node/beacon_chain/src/metrics.rs @@ -1689,6 +1689,33 @@ pub static BLOBS_FROM_EL_RECEIVED: LazyLock> = LazyLock::new(| ) }); +/* + * Standardized getBlobs metrics across clients from https://github.com/ethereum/beacon-metrics + */ +pub static BEACON_ENGINE_GET_BLOBS_V2_REQUESTS_TOTAL: LazyLock> = + LazyLock::new(|| { + try_create_int_counter( + "beacon_engine_getBlobsV2_requests_total", + "Total number of engine_getBlobsV2 requests made to the execution layer", + ) + }); + +pub static BEACON_ENGINE_GET_BLOBS_V2_RESPONSES_TOTAL: LazyLock> = + LazyLock::new(|| { + try_create_int_counter( + "beacon_engine_getBlobsV2_responses_total", + "Total number of successful engine_getBlobsV2 responses from the execution layer", + ) + }); + +pub static BEACON_ENGINE_GET_BLOBS_V2_REQUEST_DURATION_SECONDS: LazyLock> = + LazyLock::new(|| { + try_create_histogram( + "beacon_engine_getBlobsV2_request_duration_seconds", + "Duration of engine_getBlobsV2 requests to the execution layer in seconds", + ) + }); + /* * Light server message verification */