#[derive(Debug, Clone)]
pub struct Metrics;
impl Metrics {
pub const PIPELINE_ORIGIN: &str = "kona_derive_pipeline_origin";
pub const PIPELINE_STEP_BLOCK: &str = "kona_derive_pipeline_step_block";
pub const PIPELINE_BATCH_READER_SET: &str = "kona_derive_batch_reader_set";
pub const PIPELINE_ORIGIN_ADVANCE: &str = "kona_derive_pipeline_origin_advance";
pub const SYSTEM_CONFIG_UPDATE: &str = "kona_derive_system_config_update";
pub const PIPELINE_FRAME_QUEUE_BUFFER: &str = "kona_derive_frame_queue_buffer";
pub const PIPELINE_FRAME_QUEUE_MEM: &str = "kona_derive_frame_queue_mem";
pub const PIPELINE_CHANNEL_BUFFER: &str = "kona_derive_channel_buffer";
pub const PIPELINE_CHANNEL_MEM: &str = "kona_derive_channel_mem";
pub const PIPELINE_CHANNEL_TIMEOUT: &str = "kona_derive_blocks_until_channel_timeout";
pub const PIPELINE_MAX_RLP_BYTES: &str = "kona_derive_max_rlp_bytes";
pub const PIPELINE_BATCH_BUFFER: &str = "kona_derive_batch_buffer";
pub const PIPELINE_BATCH_MEM: &str = "kona_derive_batch_mem";
pub const PIPELINE_READ_BATCHES: &str = "kona_derive_read_batches";
pub const PIPELINE_STEPS: &str = "kona_derive_pipeline_steps";
pub const PIPELINE_PREPARED_ATTRIBUTES: &str = "kona_derive_prepared_attributes";
pub const PIPELINE_SIGNALS: &str = "kona_derive_pipeline_signals";
pub const PIPELINE_L1_BLOCKS_START: &str = "kona_derive_l1_blocks_start";
pub const PIPELINE_L1_BLOCKS_END: &str = "kona_derive_l1_blocks_end";
pub const PIPELINE_DERIVED_SPAN_SIZE: &str = "kona_derive_span_size";
pub const PIPELINE_LATEST_PAYLOAD_TX_COUNT: &str = "kona_derive_payload_tx_count";
pub const PIPELINE_DATA_AVAILABILITY_PROVIDER: &str = "kona_derive_dap_sources";
pub const PIPELINE_BATCH_VALIDITY: &str = "kona_derive_batch_validity";
pub const PIPELINE_CHECK_BATCH_PREFIX: &str = "kona_derive_check_batch_prefix_duration";
pub const PIPELINE_ATTRIBUTES_BUILD_DURATION: &str = "kona_derive_attributes_build_duration";
pub const PIPELINE_PAYLOAD_ATTRIBUTES_BUFFER: &str = "kona_derive_payload_attributes_buffer";
pub const PIPELINE_LATEST_SYS_CONFIG_UPDATE: &'static str =
"kona_genesis_latest_system_config_update";
pub const PIPELINE_SYS_CONFIG_UPDATE_ERROR: &'static str =
"kona_genesis_sys_config_update_error";
pub const PIPELINE_LATEST_DECOMPRESSED_BATCH_SIZE: &str =
"kona_derive_latest_decompressed_batch_size";
pub const PIPELINE_LATEST_DECOMPRESSED_BATCH_TYPE: &str =
"kona_derive_latest_decompressed_batch_type";
}
impl Metrics {
#[cfg(feature = "metrics")]
pub fn init() {
Self::describe();
Self::zero();
}
#[cfg(feature = "metrics")]
pub fn describe() {
metrics::describe_gauge!(
Self::PIPELINE_SYS_CONFIG_UPDATE_ERROR,
"The block height at which a system config update errored"
);
metrics::describe_gauge!(
Self::PIPELINE_LATEST_SYS_CONFIG_UPDATE,
"The latest block number for a system config update"
);
metrics::describe_gauge!(
Self::PIPELINE_LATEST_DECOMPRESSED_BATCH_SIZE,
"The latest decompressed batch size"
);
metrics::describe_gauge!(
Self::PIPELINE_LATEST_DECOMPRESSED_BATCH_TYPE,
"The latest decompressed batch type"
);
metrics::describe_gauge!(
Self::PIPELINE_ORIGIN,
"The block height of the pipeline l1 origin"
);
metrics::describe_gauge!(
Self::PIPELINE_BATCH_VALIDITY,
"The validity of the batch being processed",
);
metrics::describe_gauge!(
Self::PIPELINE_DATA_AVAILABILITY_PROVIDER,
"The source of pipeline data"
);
metrics::describe_gauge!(
Self::PIPELINE_DERIVED_SPAN_SIZE,
"The number of payload attributes in the current span"
);
metrics::describe_gauge!(
Self::PIPELINE_LATEST_PAYLOAD_TX_COUNT,
"The number of transactions in the latest derived payload attributes"
);
metrics::describe_gauge!(Self::PIPELINE_READ_BATCHES, "The read batches");
metrics::describe_gauge!(Self::PIPELINE_BATCH_READER_SET, "If the batch reader is set");
metrics::describe_gauge!(Self::PIPELINE_L1_BLOCKS_START, "Earliest l1 blocks height");
metrics::describe_gauge!(Self::PIPELINE_L1_BLOCKS_END, "Latest l1 blocks height");
metrics::describe_gauge!(
Self::PIPELINE_STEP_BLOCK,
"The latest L2 block height that the pipeline stepped on"
);
metrics::describe_histogram!(
Self::PIPELINE_CHECK_BATCH_PREFIX,
"The time it takes to validate a span batch"
);
metrics::describe_histogram!(
Self::PIPELINE_ORIGIN_ADVANCE,
"The amount of time it takes to advance the pipeline origin"
);
metrics::describe_histogram!(
Self::SYSTEM_CONFIG_UPDATE,
"The time it takes to update the system config"
);
metrics::describe_gauge!(
Self::PIPELINE_FRAME_QUEUE_BUFFER,
"The number of frames in the frame queue"
);
metrics::describe_gauge!(
Self::PIPELINE_FRAME_QUEUE_MEM,
"The memory size of frames held in the frame queue"
);
metrics::describe_gauge!(
Self::PIPELINE_CHANNEL_BUFFER,
"The number of channels in the channel assembler stage"
);
metrics::describe_gauge!(
Self::PIPELINE_CHANNEL_MEM,
"The memory size of channels held in the channel assembler stage"
);
metrics::describe_gauge!(
Self::PIPELINE_CHANNEL_TIMEOUT,
"The number of blocks until the next channel times out"
);
metrics::describe_gauge!(
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"
);
metrics::describe_gauge!(
Self::PIPELINE_STEPS,
"The total number of pipeline steps on the derivation pipeline"
);
metrics::describe_gauge!(
Self::PIPELINE_PREPARED_ATTRIBUTES,
"The total number of prepared attributes generated by the derivation pipeline"
);
metrics::describe_gauge!(
Self::PIPELINE_SIGNALS,
"Number of times the pipeline has been signalled"
);
metrics::describe_histogram!(
Self::PIPELINE_ATTRIBUTES_BUILD_DURATION,
"The time it takes to build payload attributes"
);
metrics::describe_gauge!(
Self::PIPELINE_PAYLOAD_ATTRIBUTES_BUFFER,
"The number of payload attributes buffered in the pipeline"
);
}
#[cfg(feature = "metrics")]
pub fn zero() {
kona_macros::set!(gauge, Self::PIPELINE_BATCH_READER_SET, 0);
kona_macros::set!(gauge, Self::PIPELINE_DATA_AVAILABILITY_PROVIDER, "source", "blobs", 0);
kona_macros::set!(
gauge,
Self::PIPELINE_DATA_AVAILABILITY_PROVIDER,
"source",
"calldata",
0
);
kona_macros::set!(gauge, Self::PIPELINE_LATEST_SYS_CONFIG_UPDATE, 0);
kona_macros::set!(gauge, Self::PIPELINE_SYS_CONFIG_UPDATE_ERROR, 0);
kona_macros::set!(gauge, Self::PIPELINE_SIGNALS, "type", "reset", 0);
kona_macros::set!(gauge, Self::PIPELINE_SIGNALS, "type", "activation", 0);
kona_macros::set!(gauge, Self::PIPELINE_SIGNALS, "type", "flush_channel", 0);
kona_macros::set!(gauge, Self::PIPELINE_READ_BATCHES, "type", "single", 0);
kona_macros::set!(gauge, Self::PIPELINE_READ_BATCHES, "type", "span", 0);
kona_macros::set!(gauge, Self::PIPELINE_STEPS, 0);
kona_macros::set!(gauge, Self::PIPELINE_PREPARED_ATTRIBUTES, 0);
kona_macros::set!(gauge, Self::PIPELINE_BATCH_BUFFER, 0);
kona_macros::set!(gauge, Self::PIPELINE_CHANNEL_BUFFER, 0);
kona_macros::set!(gauge, Self::PIPELINE_FRAME_QUEUE_BUFFER, 0);
kona_macros::set!(gauge, Self::PIPELINE_PAYLOAD_ATTRIBUTES_BUFFER, 0);
}
}