Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(metrics): add label to the state keeper transaction inclusion metric; refine buckets #1093

Merged
merged 1 commit into from
Feb 16, 2024
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
2 changes: 1 addition & 1 deletion core/lib/zksync_core/src/api_server/web3/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ApiTransportLabel, Histogram<usize>>,
/// Number of currently open WebSocket sessions.
pub ws_open_sessions: Gauge,
Expand Down
8 changes: 4 additions & 4 deletions core/lib/zksync_core/src/state_keeper/io/seal_logic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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},
Expand Down Expand Up @@ -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()));
Expand Down
25 changes: 23 additions & 2 deletions core/lib/zksync_core/src/state_keeper/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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")]
Expand All @@ -53,8 +74,8 @@ pub(crate) struct StateKeeperMetrics {
#[metrics(buckets = Buckets::LATENCIES)]
pub load_previous_miniblock_header: Histogram<Duration>,
/// 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<Duration>,
#[metrics(buckets = INCLUSION_DELAY_BUCKETS)]
pub transaction_inclusion_delay: Family<TxExecutionType, Histogram<Duration>>,
/// Time spent by the state keeper on transaction execution.
#[metrics(buckets = Buckets::LATENCIES)]
pub tx_execution_time: Family<TxExecutionStage, Histogram<Duration>>,
Expand Down
Loading