diff --git a/core/lib/zksync_core/src/api_server/web3/metrics.rs b/core/lib/zksync_core/src/api_server/web3/metrics.rs index 44edd032f69..28071c9a37d 100644 --- a/core/lib/zksync_core/src/api_server/web3/metrics.rs +++ b/core/lib/zksync_core/src/api_server/web3/metrics.rs @@ -143,7 +143,7 @@ pub(super) struct ApiMetrics { /// Number of transaction submission errors for a specific submission error reason. #[metrics(labels = ["reason"])] pub submit_tx_error: LabeledFamily<&'static str, Counter>, - #[metrics(buckets = Buckets::linear(0.0..=10.0, 1.0))] + #[metrics(buckets = Buckets::exponential(1.0..=128.0, 2.0))] pub web3_in_flight_requests: Family>, /// Number of currently open WebSocket sessions. pub ws_open_sessions: Gauge, diff --git a/core/lib/zksync_core/src/state_keeper/io/seal_logic.rs b/core/lib/zksync_core/src/state_keeper/io/seal_logic.rs index f835d776ba6..85f7d3024c6 100644 --- a/core/lib/zksync_core/src/state_keeper/io/seal_logic.rs +++ b/core/lib/zksync_core/src/state_keeper/io/seal_logic.rs @@ -34,8 +34,8 @@ use crate::{ metrics::{BlockStage, MiniblockStage, APP_METRICS}, state_keeper::{ metrics::{ - L1BatchSealStage, MiniblockSealStage, KEEPER_METRICS, L1_BATCH_METRICS, - MINIBLOCK_METRICS, + L1BatchSealStage, MiniblockSealStage, TxExecutionType, KEEPER_METRICS, + L1_BATCH_METRICS, MINIBLOCK_METRICS, }, types::ExecutionMetricsForCriteria, updates::{MiniblockSealCommand, MiniblockUpdates, UpdatesManager}, @@ -481,8 +481,8 @@ impl MiniblockSealCommand { "Transaction spent >10m in mempool before being included in a miniblock" ) } - KEEPER_METRICS - .transaction_inclusion_delay + KEEPER_METRICS.transaction_inclusion_delay + [&TxExecutionType::from_is_l1(tx.transaction.is_l1())] .observe(inclusion_delay) }); progress.observe(Some(self.miniblock.executed_transactions.len())); diff --git a/core/lib/zksync_core/src/state_keeper/metrics.rs b/core/lib/zksync_core/src/state_keeper/metrics.rs index 181447e9761..3e840d85538 100644 --- a/core/lib/zksync_core/src/state_keeper/metrics.rs +++ b/core/lib/zksync_core/src/state_keeper/metrics.rs @@ -31,6 +31,27 @@ pub(crate) enum TxExecutionStage { DryRunRollback, } +#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, EncodeLabelValue, EncodeLabelSet)] +#[metrics(label = "tx_execution_type", rename_all = "snake_case")] +pub(crate) enum TxExecutionType { + L1, + L2, +} + +impl TxExecutionType { + pub fn from_is_l1(is_l1: bool) -> TxExecutionType { + match is_l1 { + true => TxExecutionType::L1, + false => TxExecutionType::L2, + } + } +} + +const INCLUSION_DELAY_BUCKETS: Buckets = Buckets::values(&[ + 0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.9, + 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 20.0, 30.0, 60.0, 120.0, 240.0, +]); + /// General-purpose state keeper metrics. #[derive(Debug, Metrics)] #[metrics(prefix = "server_state_keeper")] @@ -53,8 +74,8 @@ pub(crate) struct StateKeeperMetrics { #[metrics(buckets = Buckets::LATENCIES)] pub load_previous_miniblock_header: Histogram, /// The time it takes for transactions to be included in a block. Representative of the time user must wait before their transaction is confirmed. - #[metrics(buckets = Buckets::LATENCIES)] - pub transaction_inclusion_delay: Histogram, + #[metrics(buckets = INCLUSION_DELAY_BUCKETS)] + pub transaction_inclusion_delay: Family>, /// Time spent by the state keeper on transaction execution. #[metrics(buckets = Buckets::LATENCIES)] pub tx_execution_time: Family>,