mirror of
https://github.com/hl-archive-node/nanoreth.git
synced 2025-12-06 02:49:55 +00:00
add metrics for engine_getBlobsV1 (#14621)
This commit is contained in:
@ -1006,15 +1006,30 @@ where
|
||||
versioned_hashes: Vec<B256>,
|
||||
) -> RpcResult<Vec<Option<BlobAndProofV1>>> {
|
||||
trace!(target: "rpc::engine", "Serving engine_getBlobsV1");
|
||||
let start = Instant::now();
|
||||
|
||||
if versioned_hashes.len() > MAX_BLOB_LIMIT {
|
||||
return Err(EngineApiError::BlobRequestTooLarge { len: versioned_hashes.len() }.into())
|
||||
}
|
||||
|
||||
Ok(self
|
||||
let res = self
|
||||
.inner
|
||||
.tx_pool
|
||||
.get_blobs_for_versioned_hashes(&versioned_hashes)
|
||||
.map_err(|err| EngineApiError::Internal(Box::new(err)))?)
|
||||
.map_err(|err| EngineApiError::Internal(Box::new(err)).into());
|
||||
|
||||
let elapsed = start.elapsed();
|
||||
self.inner.metrics.latency.get_blobs_v1.record(elapsed);
|
||||
|
||||
if let Ok(blobs) = &res {
|
||||
let blobs_found = blobs.iter().flatten().count();
|
||||
let blobs_missed = versioned_hashes.len() - blobs_found;
|
||||
|
||||
self.inner.metrics.blob_metrics.blob_count.increment(blobs_found as u64);
|
||||
self.inner.metrics.blob_metrics.blob_misses.increment(blobs_missed as u64);
|
||||
}
|
||||
|
||||
res
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -14,6 +14,8 @@ pub(crate) struct EngineApiMetrics {
|
||||
pub(crate) fcu_response: ForkchoiceUpdatedResponseMetrics,
|
||||
/// Engine API newPayload response type metrics
|
||||
pub(crate) new_payload_response: NewPayloadStatusResponseMetrics,
|
||||
/// Blob-related metrics
|
||||
pub(crate) blob_metrics: BlobMetrics,
|
||||
}
|
||||
|
||||
/// Beacon consensus engine latency metrics.
|
||||
@ -50,6 +52,8 @@ pub(crate) struct EngineApiLatencyMetrics {
|
||||
pub(crate) get_payload_bodies_by_hash_v1: Histogram,
|
||||
/// Latency for `engine_exchangeTransitionConfigurationV1`
|
||||
pub(crate) exchange_transition_configuration: Histogram,
|
||||
/// Latency for `engine_getBlobsV1`
|
||||
pub(crate) get_blobs_v1: Histogram,
|
||||
}
|
||||
|
||||
/// Metrics for engine API forkchoiceUpdated responses.
|
||||
@ -104,6 +108,15 @@ pub(crate) struct NewPayloadStatusResponseMetrics {
|
||||
pub(crate) new_payload_last: Gauge,
|
||||
}
|
||||
|
||||
#[derive(Metrics)]
|
||||
#[metrics(scope = "engine.rpc.blobs")]
|
||||
pub(crate) struct BlobMetrics {
|
||||
/// Count of blobs successfully retrieved
|
||||
pub(crate) blob_count: Counter,
|
||||
/// Count of blob misses
|
||||
pub(crate) blob_misses: Counter,
|
||||
}
|
||||
|
||||
impl NewPayloadStatusResponseMetrics {
|
||||
/// Increment the newPayload counter based on the given rpc result
|
||||
pub(crate) fn update_response_metrics(
|
||||
|
||||
Reference in New Issue
Block a user