Skip to content

Commit dc1b00c

Browse files
authored
Improve metrics so we could better plot them (#193)
1 parent 69a58d8 commit dc1b00c

File tree

2 files changed

+24
-12
lines changed

2 files changed

+24
-12
lines changed

crates/op-rbuilder/src/builders/flashblocks/payload.rs

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -281,9 +281,11 @@ where
281281
first_flashblock_offset = first_flashblock_offset.as_millis(),
282282
flashblocks_interval = self.config.specific.interval.as_millis(),
283283
);
284-
ctx.metrics
285-
.target_flashblock
286-
.record(flashblocks_per_block as f64);
284+
ctx.metrics.reduced_flashblocks_number.record(
285+
self.config
286+
.flashblocks_per_block()
287+
.saturating_sub(flashblocks_per_block) as f64,
288+
);
287289
ctx.metrics
288290
.first_flashblock_time_offset
289291
.record(first_flashblock_offset.as_millis() as f64);
@@ -490,9 +492,14 @@ where
490492
// Exit loop if channel closed or cancelled
491493
ctx.metrics.block_built_success.increment(1);
492494
ctx.metrics.flashblock_count.record(flashblock_count as f64);
495+
ctx.metrics
496+
.missing_flashblocks_count
497+
.record(flashblocks_per_block.saturating_sub(flashblock_count) as f64);
493498
debug!(
494499
target: "payload_builder",
495-
message = "Payload building complete, channel closed or job cancelled"
500+
message = "Payload building complete, channel closed or job cancelled",
501+
missing_falshblocks = flashblocks_per_block.saturating_sub(flashblock_count),
502+
reduced_flashblocks = self.config.flashblocks_per_block().saturating_sub(flashblocks_per_block),
496503
);
497504
span.record("flashblock_count", flashblock_count);
498505
return Ok(());
@@ -579,14 +586,17 @@ where
579586
self.config.specific.interval,
580587
);
581588
};
582-
self.metrics
583-
.flashblock_time_drift
584-
.record(time_drift.as_millis() as f64);
589+
self.metrics.flashblocks_time_drift.record(
590+
self.config
591+
.block_time
592+
.as_millis()
593+
.saturating_sub(time_drift.as_millis()) as f64,
594+
);
585595
debug!(
586596
target: "payload_builder",
587597
message = "Time drift for building round",
588598
?target_time,
589-
?time_drift,
599+
time_drift = self.config.block_time.as_millis().saturating_sub(time_drift.as_millis()),
590600
?timestamp
591601
);
592602
// This is extra check to ensure that we would account at least for block time in case we have any timer discrepancies.

crates/op-rbuilder/src/metrics.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,12 @@ pub struct OpRBuilderMetrics {
7676
pub da_block_size_limit: Gauge,
7777
/// Da tx size limit
7878
pub da_tx_size_limit: Gauge,
79-
/// Desired number of flashblocks
80-
pub target_flashblock: Histogram,
81-
/// Time drift that we account for in the beginning of block building
82-
pub flashblock_time_drift: Histogram,
79+
/// How much less flashblocks we issue to be on time with block construction
80+
pub reduced_flashblocks_number: Histogram,
81+
/// How much less flashblocks we issued in reality, comparing to calculated number for block
82+
pub missing_flashblocks_count: Histogram,
83+
/// How much time we have deducted from block building time
84+
pub flashblocks_time_drift: Histogram,
8385
/// Time offset we used for first flashblock
8486
pub first_flashblock_time_offset: Histogram,
8587
/// Number of requests sent to the eth_sendBundle endpoint

0 commit comments

Comments
 (0)