Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions crates/protocol/derive/src/metrics/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@

/// Identifier for the gauge that tracks the maximum rlp byte size per channel.
pub const PIPELINE_MAX_RLP_BYTES: &str = "kona_derive_max_rlp_bytes";

/// Identifier for the batch stream stage singular batch buffer size.
pub const PIPELINE_BATCH_BUFFER: &str = "kona_derive_batch_buffer";

/// Identifier for the batch stream stage batch memory overhead gauge.
pub const PIPELINE_BATCH_MEM: &str = "kona_derive_batch_mem";
}

impl Metrics {
Expand Down Expand Up @@ -84,16 +90,21 @@
Self::PIPELINE_MAX_RLP_BYTES,
"The maximum rlp byte size of a channel"
);
metrics::describe_gauge!(
Self::PIPELINE_BATCH_BUFFER,
"The number of batches held in the batch stream stage"
);
metrics::describe_gauge!(
Self::PIPELINE_BATCH_MEM,
"The memory size of batches held in the batch stream stage"
);

Check warning on line 100 in crates/protocol/derive/src/metrics/mod.rs

View check run for this annotation

Codecov / codecov/patch

crates/protocol/derive/src/metrics/mod.rs#L93-L100

Added lines #L93 - L100 were not covered by tests
}

/// Initializes metrics to 0 so they can be queried immediately.
#[cfg(feature = "metrics")]
pub fn zero() {
kona_macros::set!(gauge, Self::PIPELINE_FRAME_QUEUE_BUFFER, 0);
kona_macros::set!(gauge, Self::PIPELINE_FRAME_QUEUE_MEM, 0);
kona_macros::set!(gauge, Self::PIPELINE_CHANNEL_BUFFER, 0);
kona_macros::set!(gauge, Self::PIPELINE_CHANNEL_MEM, 0);
kona_macros::set!(gauge, Self::PIPELINE_CHANNEL_TIMEOUT, 0);
kona_macros::set!(gauge, Self::PIPELINE_MAX_RLP_BYTES, 0);
}
}
15 changes: 15 additions & 0 deletions crates/protocol/derive/src/stages/batch/batch_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,13 @@ where
})?,
);
}
#[cfg(feature = "metrics")]
{
let batch_count = self.buffer.len() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_BATCH_BUFFER, batch_count);
let batch_size = std::mem::size_of_val(&self.buffer) as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_BATCH_MEM, batch_size);
}
Ok(())
}
}
Expand Down Expand Up @@ -122,6 +129,14 @@ where
parent: L2BlockInfo,
l1_origins: &[BlockInfo],
) -> PipelineResult<Batch> {
#[cfg(feature = "metrics")]
{
let batch_count = self.buffer.len() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_BATCH_BUFFER, batch_count);
let batch_size = std::mem::size_of_val(&self.buffer) as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_BATCH_MEM, batch_size);
}

// If the stage is not active, "pass" the next batch
// through this stage to the BatchQueue stage.
if !self.is_active()? {
Expand Down
Loading