Skip to content

Commit

Permalink
use different metric name for each shard
Browse files Browse the repository at this point in the history
  • Loading branch information
areshand committed Sep 26, 2024
1 parent 5ad601c commit 55fdf3f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 32 deletions.
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

0 comments on commit 55fdf3f

Please sign in to comment.