use aptos_metrics_core::{
op_counters::DurationHistogram, register_histogram, register_histogram_vec,
register_int_counter, register_int_counter_vec, register_int_gauge, register_int_gauge_vec,
Histogram, HistogramVec, IntCounter, IntCounterVec, IntGauge, IntGaugeVec,
};
use once_cell::sync::Lazy;
pub static OP_COUNTERS: Lazy<aptos_metrics_core::op_counters::OpMetrics> =
Lazy::new(|| aptos_metrics_core::op_counters::OpMetrics::new_and_registered("consensus"));
pub static ERROR_COUNT: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_error_count",
"Total number of errors in main loop"
)
.unwrap()
});
pub static LAST_COMMITTED_ROUND: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_last_committed_round",
"This counter is set to the round of the highest committed block."
)
.unwrap()
});
pub static LAST_COMMITTED_VERSION: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_last_committed_version",
"The counter corresponds to the version of the last committed ledger info."
)
.unwrap()
});
pub static COMMITTED_BLOCKS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_committed_blocks_count",
"Count of the committed blocks since last restart."
)
.unwrap()
});
pub static COMMITTED_TXNS_COUNT: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_committed_txns_count",
"Count of the transactions since last restart. state is success or failed",
&["state"]
)
.unwrap()
});
pub static PROPOSALS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!("aptos_consensus_proposals_count", "Count of the block proposals sent by this validator since last restart (both primary and secondary)").unwrap()
});
pub static VOTE_NIL_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_vote_nil_count",
"Count the number of times a validator voted for a nil block since last restart."
)
.unwrap()
});
pub static COMMITTED_PROPOSALS_IN_WINDOW: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"aptos_committed_proposals_in_window",
"Total number committed proposals in the current reputation window",
&["address"]
)
.unwrap()
});
pub static FAILED_PROPOSALS_IN_WINDOW: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"aptos_failed_proposals_in_window",
"Total number of failed proposals in the current reputation window",
&["address"]
)
.unwrap()
});
pub static COMMITTED_VOTES_IN_WINDOW: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
"aptos_committed_votes_in_window",
"Total number of committed votes in the current reputation window",
&["address"]
)
.unwrap()
});
pub static LEADER_REPUTATION_ROUND_HISTORY_SIZE: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_leader_reputation_round_history_size",
"Total number of new block events in the current reputation window"
)
.unwrap()
});
pub static CURRENT_ROUND: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_current_round",
"This counter is set to the last round reported by the local round_state."
)
.unwrap()
});
pub static QC_ROUNDS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_qc_rounds_count",
"Count of the rounds that gathered QC since last restart."
)
.unwrap()
});
pub static TIMEOUT_ROUNDS_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_timeout_rounds_count",
"Count of the timeout rounds since last restart (close to 0 in happy path)."
)
.unwrap()
});
pub static TIMEOUT_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!("aptos_consensus_timeout_count", "Count the number of timeouts a node experienced since last restart (close to 0 in happy path).").unwrap()
});
pub static ROUND_TIMEOUT_MS: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_round_timeout_s",
"The timeout of the current round."
)
.unwrap()
});
pub static SYNC_INFO_MSGS_SENT_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_sync_info_msg_sent_count",
"Counts the number of times the sync info message has been set since last restart."
)
.unwrap()
});
pub static EPOCH: Lazy<IntGauge> =
Lazy::new(|| register_int_gauge!("aptos_consensus_epoch", "Current epoch num").unwrap());
pub static CURRENT_EPOCH_VALIDATORS: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_current_epoch_validators",
"The number of validators in the current epoch"
)
.unwrap()
});
pub static NUM_BLOCKS_IN_TREE: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_num_blocks_in_tree",
"Counter for the number of blocks in the block tree (including the root)."
)
.unwrap()
});
pub static NUM_TXNS_PER_BLOCK: Lazy<Histogram> = Lazy::new(|| {
register_histogram!(
"aptos_consensus_num_txns_per_block",
"Histogram for the number of txns per (committed) blocks."
)
.unwrap()
});
pub static BLOCK_TRACING: Lazy<HistogramVec> = Lazy::new(|| {
register_histogram_vec!(
"aptos_consensus_block_tracing",
"Histogram for different stages of a block",
&["stage"]
)
.unwrap()
});
pub static WAIT_DURATION_S: Lazy<DurationHistogram> = Lazy::new(|| {
DurationHistogram::new(register_histogram!("aptos_consensus_wait_duration_s", "Histogram of the time it requires to wait before inserting blocks into block store. Measured as the block's timestamp minus the local timestamp.").unwrap())
});
pub static PENDING_SELF_MESSAGES: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_pending_self_messages",
"Count of the pending messages sent to itself in the channel"
)
.unwrap()
});
pub static PENDING_ROUND_TIMEOUTS: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_pending_round_timeouts",
"Count of the pending outbound round timeouts"
)
.unwrap()
});
pub static PENDING_CONSENSUS_NETWORK_EVENTS: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_pending_network_events",
"Counters(queued,dequeued,dropped) related to pending network notifications to Consensus",
&["state"]
)
.unwrap()
});
pub static PENDING_STATE_SYNC_NOTIFICATION: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_pending_state_sync_notification",
"Count of the pending state sync notification"
)
.unwrap()
});
pub static PENDING_QUORUM_STORE_COMMIT_NOTIFICATION: Lazy<IntGauge> = Lazy::new(|| {
register_int_gauge!(
"aptos_consensus_pending_quorum_store_commit_notification",
"Count of the pending quorum store commit notification"
)
.unwrap()
});
pub static BUFFER_MANAGER_MSGS: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_buffer_manager_msgs_count",
"Counters(queued,dequeued,dropped) related to pending commit votes",
&["state"]
)
.unwrap()
});
pub static CONSENSUS_CHANNEL_MSGS: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_channel_msgs_count",
"Counters(queued,dequeued,dropped) related to consensus channel",
&["state"]
)
.unwrap()
});
pub static ROUND_MANAGER_CHANNEL_MSGS: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_round_manager_msgs_count",
"Counters(queued,dequeued,dropped) related to consensus channel",
&["state"]
)
.unwrap()
});
pub static BLOCK_RETRIEVAL_CHANNEL_MSGS: Lazy<IntCounterVec> = Lazy::new(|| {
register_int_counter_vec!(
"aptos_consensus_block_retrieval_channel_msgs_count",
"Counters(queued,dequeued,dropped) related to block retrieval channel",
&["state"]
)
.unwrap()
});
pub static BUFFER_MANAGER_RETRY_COUNT: Lazy<IntCounter> = Lazy::new(|| {
register_int_counter!(
"aptos_consensus_buffer_manager_retry_count",
"Count of the buffer manager retry requests since last restart"
)
.unwrap()
});