Skip to content
This repository was archived by the owner on Jan 16, 2026. It is now read-only.
Open
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
24 changes: 17 additions & 7 deletions crates/protocol/derive/src/stages/channel/channel_assembler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,21 @@ where
self.channel = Some(Channel::new(next_frame.id, origin));
}

let count = if self.channel.is_some() { 1 } else { 0 };
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_BUFFER, count);
#[cfg(feature = "metrics")]
{
let count = if self.channel.is_some() { 1 } else { 0 };
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_BUFFER, count);
}

if let Some(channel) = self.channel.as_mut() {
// Track the number of blocks until the channel times out.
let timeout = channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp);
let margin = timeout.saturating_sub(origin.number) as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_TIMEOUT, margin);
#[cfg(feature = "metrics")]
{
let timeout =
channel.open_block_number() + self.cfg.channel_timeout(origin.timestamp);
let margin = timeout.saturating_sub(origin.number) as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_TIMEOUT, margin);
}

// Add the frame to the channel. If this fails, return NotEnoughData and discard the
// frame.
Expand All @@ -122,8 +129,11 @@ where
return Err(PipelineError::NotEnoughData.temp());
}

let size = channel.size() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_MEM, size);
#[cfg(feature = "metrics")]
{
let size = channel.size() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_CHANNEL_MEM, size);
}

let max_rlp_bytes_per_channel = if self.cfg.is_fjord_active(origin.timestamp) {
MAX_RLP_BYTES_PER_CHANNEL_FJORD
Expand Down
35 changes: 19 additions & 16 deletions crates/protocol/derive/src/stages/channel/channel_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,25 @@ where
match next_batch.decompress() {
Ok(()) => {
// Record the decompressed size and type.
let size = next_batch.decompressed.len() as f64;
let ty = if next_batch.brotli_used {
BatchReader::CHANNEL_VERSION_BROTLI
} else {
BatchReader::ZLIB_DEFLATE_COMPRESSION_METHOD
};
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_LATEST_DECOMPRESSED_BATCH_SIZE,
size
);
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_LATEST_DECOMPRESSED_BATCH_TYPE,
ty as f64
);
#[cfg(feature = "metrics")]
{
let size = next_batch.decompressed.len() as f64;
let ty = if next_batch.brotli_used {
BatchReader::CHANNEL_VERSION_BROTLI
} else {
BatchReader::ZLIB_DEFLATE_COMPRESSION_METHOD
};
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_LATEST_DECOMPRESSED_BATCH_SIZE,
size
);
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_LATEST_DECOMPRESSED_BATCH_TYPE,
ty as f64
);
}
}
Err(err) => {
debug!(target: "channel_reader", ?err, "Failed to decompress batch");
Expand Down
17 changes: 10 additions & 7 deletions crates/protocol/derive/src/stages/frame_queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,16 @@ where
self.queue.extend(frames);

// Update metrics with last frame count
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_FRAME_QUEUE_BUFFER,
self.queue.len() as f64
);
let queue_size = self.queue.iter().map(|f| f.size()).sum::<usize>() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_FRAME_QUEUE_MEM, queue_size);
#[cfg(feature = "metrics")]
{
kona_macros::set!(
gauge,
crate::metrics::Metrics::PIPELINE_FRAME_QUEUE_BUFFER,
self.queue.len() as f64
);
let queue_size = self.queue.iter().map(|f| f.size()).sum::<usize>() as f64;
kona_macros::set!(gauge, crate::metrics::Metrics::PIPELINE_FRAME_QUEUE_MEM, queue_size);
}

// Prune frames if Holocene is active.
let origin = self.origin().ok_or(PipelineError::MissingOrigin.crit())?;
Expand Down
Loading