forked from aptos-labs/aptos-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[State Sync] Add simple metrics to the state sync driver.
Closes: aptos-labs#522
- Loading branch information
Showing
7 changed files
with
244 additions
and
14 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
state-sync/state-sync-v2/state-sync-driver/src/metrics.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
// Copyright (c) Aptos | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
use aptos_metrics::{register_int_counter_vec, register_int_gauge_vec, IntCounterVec, IntGaugeVec}; | ||
use once_cell::sync::Lazy; | ||
|
||
/// Useful metric labels | ||
pub const DRIVER_CLIENT_NOTIFICATION: &str = "driver_client_notification"; | ||
pub const DRIVER_CONSENSUS_COMMIT_NOTIFICATION: &str = "driver_consensus_commit_notification"; | ||
pub const DRIVER_CONSENSUS_SYNC_NOTIFICATION: &str = "driver_consensus_sync_notification"; | ||
pub const STORAGE_SYNCHRONIZER_PENDING_DATA: &str = "storage_synchronizer_pending_data"; | ||
|
||
/// An enum of storage synchronizer operations performed by state sync | ||
pub enum StorageSynchronizerOperations { | ||
AppliedTransactionOutputs, // Applied a chunk of transactions outputs. | ||
ExecutedTransactions, // Executed a chunk of transactions. | ||
SyncedAccounts, // Wrote a chunk of accounts to storage. | ||
SyncedTransactions, // Wrote a chunk of transactions and outputs to storage. | ||
} | ||
|
||
impl StorageSynchronizerOperations { | ||
pub fn get_label(&self) -> &'static str { | ||
match self { | ||
StorageSynchronizerOperations::AppliedTransactionOutputs => { | ||
"applied_transaction_outputs" | ||
} | ||
StorageSynchronizerOperations::ExecutedTransactions => "executed_transactions", | ||
StorageSynchronizerOperations::SyncedAccounts => "synced_accounts", | ||
StorageSynchronizerOperations::SyncedTransactions => "synced_transactions", | ||
} | ||
} | ||
} | ||
|
||
/// Counter for state sync bootstrapper errors | ||
pub static BOOTSTRAPPER_ERRORS: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"aptos_state_sync_bootstrapper_errors", | ||
"Counters related to state sync bootstrapper errors", | ||
&["error_label"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Counter for state sync continuous syncer errors | ||
pub static CONTINUOUS_SYNCER_ERRORS: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"aptos_state_sync_continuous_syncer_errors", | ||
"Counters related to state sync continuous syncer errors", | ||
&["error_label"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Counters related to the state sync driver | ||
pub static DRIVER_COUNTERS: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"aptos_state_sync_driver_counters", | ||
"Counters related to the state sync driver", | ||
&["label"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Counter for storage synchronizer errors | ||
pub static STORAGE_SYNCHRONIZER_ERRORS: Lazy<IntCounterVec> = Lazy::new(|| { | ||
register_int_counter_vec!( | ||
"aptos_state_sync_storage_synchronizer_errors", | ||
"Counters related to storage synchronizer errors", | ||
&["error_label"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Gauges related to the storage synchronizer | ||
pub static STORAGE_SYNCHRONIZER_GAUGES: Lazy<IntGaugeVec> = Lazy::new(|| { | ||
register_int_gauge_vec!( | ||
"aptos_state_sync_storage_synchronizer_gauges", | ||
"Gauges related to the storage synchronizer", | ||
&["label"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Gauges for the storage synchronizer operations. | ||
/// Note: we keep this named "aptos_state_sync_version" to maintain backward | ||
/// compatibility with the metrics used by state sync v1. | ||
pub static STORAGE_SYNCHRONIZER_OPERATIONS: Lazy<IntGaugeVec> = Lazy::new(|| { | ||
register_int_gauge_vec!( | ||
"aptos_state_sync_version", | ||
"The versions processed by the storage synchronizer operations", | ||
&["storage_synchronizer_operation"] | ||
) | ||
.unwrap() | ||
}); | ||
|
||
/// Increments the given counter with the provided label values. | ||
pub fn increment_counter(counter: &Lazy<IntCounterVec>, label: &str) { | ||
counter.with_label_values(&[label]).inc(); | ||
} | ||
|
||
/// Increments the gauge with the specific label by the given delta | ||
pub fn increment_gauge(gauge: &Lazy<IntGaugeVec>, label: &str, delta: u64) { | ||
gauge.with_label_values(&[label]).add(delta as i64); | ||
} | ||
|
||
/// Decrements the gauge with the specific label by the given delta | ||
pub fn decrement_gauge(gauge: &Lazy<IntGaugeVec>, label: &str, delta: u64) { | ||
gauge.with_label_values(&[label]).sub(delta as i64); | ||
} | ||
|
||
/// Sets the gauge with the specific label to the given value | ||
pub fn set_gauge(gauge: &Lazy<IntGaugeVec>, label: &str, value: u64) { | ||
gauge.with_label_values(&[label]).set(value as i64); | ||
} |
Oops, something went wrong.