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

[storage] use different metric name for each shard #14666

Merged
merged 2 commits into from
Sep 26, 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
57 changes: 36 additions & 21 deletions storage/aptosdb/src/metrics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,29 +155,44 @@ pub static ROCKSDB_PROPERTIES: Lazy<IntGaugeVec> = Lazy::new(|| {
.unwrap()
});

pub(crate) static STATE_KV_DB_PROPERTIES: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
// metric name
"aptos_state_kv_db_properties",
// metric description
"StateKvDb rocksdb integer properties",
// metric labels (dimensions)
&["shard_id", "cf_name", "property_name",]
)
.unwrap()
pub(crate) static STATE_KV_DB_PROPERTIES_METRIC_VECTOR: Lazy<Vec<IntGaugeVec>> = Lazy::new(|| {
(0..16)
.map(|shard_id| {
register_int_gauge_vec!(
// metric name
&format!("aptos_state_kv_db_properties_{}", shard_id),
// metric description
&format!(
"StateKvDb rocksdb integer properties for shard {}",
shard_id
),
// metric labels (dimensions)
&["cf_name", "property_name"]
)
.unwrap()
})
.collect()
});

pub(crate) static STATE_MERKLE_DB_PROPERTIES: Lazy<IntGaugeVec> = Lazy::new(|| {
register_int_gauge_vec!(
// metric name
"aptos_state_merkle_db_properties",
// metric description
"StateMerkleDb rocksdb integer properties",
// metric labels (dimensions)
&["shard_id", "cf_name", "property_name",]
)
.unwrap()
});
pub(crate) static STATE_MERKLE_DB_PROPERTIES_METRIC_VECTOR: Lazy<Vec<IntGaugeVec>> =
Lazy::new(|| {
(0..16)
.map(|shard_id| {
register_int_gauge_vec!(
// metric name
&format!("aptos_state_merkle_db_properties_{}", shard_id),
// metric description
&format!(
"StateMerkleDb rocksdb integer properties for shard {}",
shard_id
),
// metric labels (dimensions)
&["cf_name", "property_name"]
)
.unwrap()
})
.collect()
});

// Async committer gauges:
pub(crate) static LATEST_SNAPSHOT_VERSION: Lazy<IntGauge> = Lazy::new(|| {
Expand Down
18 changes: 7 additions & 11 deletions storage/aptosdb/src/rocksdb_property_reporter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ use crate::{
},
ledger_db::LedgerDb,
metrics::{
OTHER_TIMERS_SECONDS, ROCKSDB_PROPERTIES, STATE_KV_DB_PROPERTIES,
STATE_MERKLE_DB_PROPERTIES,
OTHER_TIMERS_SECONDS, ROCKSDB_PROPERTIES, STATE_KV_DB_PROPERTIES_METRIC_VECTOR,
STATE_MERKLE_DB_PROPERTIES_METRIC_VECTOR,
},
state_kv_db::StateKvDb,
state_merkle_db::StateMerkleDb,
Expand Down Expand Up @@ -88,16 +88,12 @@ fn set_shard_property(
cf_name: &str,
db: &DB,
db_shard_id: usize,
metrics: &Lazy<IntGaugeVec>,
metrics: &Lazy<Vec<IntGaugeVec>>,
) -> Result<()> {
if !skip_reporting_cf(cf_name) {
for (rockdb_property_name, aptos_rocksdb_property_name) in &*ROCKSDB_PROPERTY_MAP {
metrics
.with_label_values(&[
&format!("{db_shard_id}"),
cf_name,
aptos_rocksdb_property_name,
])
metrics[db_shard_id]
.with_label_values(&[cf_name, aptos_rocksdb_property_name])
.set(db.get_property(cf_name, rockdb_property_name)? as i64);
}
}
Expand Down Expand Up @@ -152,7 +148,7 @@ fn update_rocksdb_properties(
cf,
state_kv_db.db_shard(shard as u8),
shard,
&STATE_KV_DB_PROPERTIES,
&STATE_KV_DB_PROPERTIES_METRIC_VECTOR,
)?;
}
}
Expand All @@ -171,7 +167,7 @@ fn update_rocksdb_properties(
cf_name,
state_merkle_db.db_shard(shard as u8),
shard,
&STATE_MERKLE_DB_PROPERTIES,
&STATE_MERKLE_DB_PROPERTIES_METRIC_VECTOR,
)?;
}
}
Expand Down
Loading