Skip to content

Commit 9eff492

Browse files
reject-imattsse
andauthored
feat(flashblocks): add metrics for current block and index (paradigmxyz#19712)
Co-authored-by: Matthias Seitz <[email protected]>
1 parent b6e6bd3 commit 9eff492

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

crates/optimism/flashblocks/src/service.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ use crate::{
77
use alloy_eips::eip2718::WithEncoded;
88
use alloy_primitives::B256;
99
use futures_util::{FutureExt, Stream, StreamExt};
10-
use metrics::Histogram;
10+
use metrics::{Gauge, Histogram};
1111
use op_alloy_rpc_types_engine::OpFlashblockPayloadBase;
1212
use reth_chain_state::{CanonStateNotification, CanonStateNotifications, CanonStateSubscriptions};
1313
use reth_evm::ConfigureEvm;
@@ -279,6 +279,7 @@ where
279279

280280
let elapsed = now.elapsed();
281281
this.metrics.execution_duration.record(elapsed.as_secs_f64());
282+
282283
trace!(
283284
target: "flashblocks",
284285
parent_hash = %new_pending.block().parent_hash(),
@@ -349,6 +350,9 @@ where
349350
index: args.last_flashblock_index,
350351
block_number: args.base.block_number,
351352
};
353+
// Record current block and index metrics
354+
this.metrics.current_block_height.set(fb_info.block_number as f64);
355+
this.metrics.current_index.set(fb_info.index as f64);
352356
// Signal that a flashblock build has started with build metadata
353357
let _ = this.in_progress_tx.send(Some(fb_info));
354358
let (tx, rx) = oneshot::channel();
@@ -389,4 +393,8 @@ struct FlashBlockServiceMetrics {
389393
last_flashblock_length: Histogram,
390394
/// The duration applying flashblock state changes in seconds.
391395
execution_duration: Histogram,
396+
/// Current block height.
397+
current_block_height: Gauge,
398+
/// Current flashblock index.
399+
current_index: Gauge,
392400
}

0 commit comments

Comments
 (0)