Skip to content

Commit 1b06a41

Browse files
apollo_storage: add panels
1 parent 7d7e230 commit 1b06a41

File tree

7 files changed

+61
-8
lines changed

7 files changed

+61
-8
lines changed

Cargo.lock

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

crates/apollo_dashboard/resources/dev_grafana.json

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -941,7 +941,28 @@
941941
"extra_params": {}
942942
}
943943
],
944-
"Storage": [],
944+
"Storage": [
945+
{
946+
"title": "storage_append_thin_state_diff_latency_seconds",
947+
"description": "Latency to append thin state diff in storage (secs)",
948+
"type": "timeseries",
949+
"exprs": [
950+
"histogram_quantile(0.50, sum by (le) (rate(storage_append_thin_state_diff_latency_seconds_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))",
951+
"histogram_quantile(0.95, sum by (le) (rate(storage_append_thin_state_diff_latency_seconds_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))"
952+
],
953+
"extra_params": {}
954+
},
955+
{
956+
"title": "storage_commit_latency_seconds",
957+
"description": "Latency to commit changes in storage (secs)",
958+
"type": "timeseries",
959+
"exprs": [
960+
"histogram_quantile(0.50, sum by (le) (rate(storage_commit_latency_seconds_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))",
961+
"histogram_quantile(0.95, sum by (le) (rate(storage_commit_latency_seconds_bucket{cluster=~\"$cluster\", namespace=~\"$namespace\"}[5m])))"
962+
],
963+
"extra_params": {}
964+
}
965+
],
945966
"MempoolP2p": [
946967
{
947968
"title": "apollo_mempool_p2p_num_connected_peers",
@@ -2537,4 +2558,4 @@
25372558
}
25382559
]
25392560
}
2540-
}
2561+
}
Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,17 @@
1-
use crate::dashboard::Row;
1+
use apollo_storage::metrics::{STORAGE_APPEND_THIN_STATE_DIFF_LATENCY, STORAGE_COMMIT_LATENCY};
2+
3+
use crate::dashboard::{Panel, PanelType, Row};
4+
5+
fn get_storage_append_thin_state_diff_latency() -> Panel {
6+
Panel::from_hist(STORAGE_APPEND_THIN_STATE_DIFF_LATENCY, PanelType::TimeSeries)
7+
}
8+
fn get_storage_commit_latency() -> Panel {
9+
Panel::from_hist(STORAGE_COMMIT_LATENCY, PanelType::TimeSeries)
10+
}
211

312
pub(crate) fn get_storage_row() -> Row {
4-
Row::new("Storage", vec![])
13+
Row::new(
14+
"Storage",
15+
vec![get_storage_append_thin_state_diff_latency(), get_storage_commit_latency()],
16+
)
517
}

crates/apollo_storage/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ required-features = ["clap", "statistical"]
1818
[dependencies]
1919
apollo_config.workspace = true
2020
apollo_proc_macros.workspace = true
21+
apollo_metrics.workspace = true
2122
byteorder.workspace = true
2223
cairo-lang-casm = { workspace = true, features = ["parity-scale-codec"] }
2324
cairo-lang-starknet-classes.workspace = true

crates/apollo_storage/src/lib.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ pub mod class_manager;
8383
pub mod compiled_class;
8484
#[cfg(feature = "document_calls")]
8585
pub mod document_calls;
86+
#[allow(missing_docs)]
87+
pub mod metrics;
8688
pub mod storage_metrics;
8789
// TODO(yair): Make the compression_utils module pub(crate) or extract it from the crate.
8890
#[doc(hidden)]
@@ -109,7 +111,7 @@ use std::sync::Arc;
109111

110112
use apollo_config::dumping::{prepend_sub_config_name, ser_param, SerializeConfig};
111113
use apollo_config::{ParamPath, ParamPrivacyInput, SerializedParam};
112-
use apollo_proc_macros::latency_histogram;
114+
use apollo_proc_macros::{latency_histogram, sequencer_latency_histogram};
113115
use body::events::EventIndex;
114116
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
115117
use db::db_stats::{DbTableStats, DbWholeStats};
@@ -151,6 +153,7 @@ use crate::db::{
151153
RW,
152154
};
153155
use crate::header::StorageBlockHeader;
156+
use crate::metrics::STORAGE_COMMIT_LATENCY;
154157
use crate::mmap_file::MMapFileStats;
155158
use crate::state::data::IndexedDeprecatedContractClass;
156159
use crate::version::{VersionStorageReader, VersionStorageWriter};
@@ -490,7 +493,7 @@ pub struct StorageTxn<'env, Mode: TransactionKind> {
490493

491494
impl StorageTxn<'_, RW> {
492495
/// Commits the changes made in the transaction to the storage.
493-
#[latency_histogram("storage_commit_latency_seconds", false)]
496+
#[sequencer_latency_histogram(STORAGE_COMMIT_LATENCY, false)]
494497
pub fn commit(self) -> StorageResult<()> {
495498
self.file_handlers.flush();
496499
Ok(self.txn.commit()?)

crates/apollo_storage/src/metrics.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
use apollo_metrics::define_metrics;
2+
3+
define_metrics!(
4+
Storage => {
5+
MetricHistogram { STORAGE_APPEND_THIN_STATE_DIFF_LATENCY, "storage_append_thin_state_diff_latency_seconds", "Latency to append thin state diff in storage (secs)" },
6+
MetricHistogram { STORAGE_COMMIT_LATENCY, "storage_commit_latency_seconds", "Latency to commit changes in storage (secs)" },
7+
},
8+
);
9+
10+
#[allow(dead_code)]
11+
pub(crate) fn register_metrics() {
12+
STORAGE_APPEND_THIN_STATE_DIFF_LATENCY.register();
13+
STORAGE_COMMIT_LATENCY.register();
14+
}

crates/apollo_storage/src/state/mod.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ mod state_test;
5656

5757
use std::collections::HashSet;
5858

59-
use apollo_proc_macros::latency_histogram;
59+
use apollo_proc_macros::{latency_histogram, sequencer_latency_histogram};
6060
use cairo_lang_starknet_classes::casm_contract_class::CasmContractClass;
6161
use indexmap::IndexMap;
6262
use starknet_api::block::BlockNumber;
@@ -71,6 +71,7 @@ use crate::db::table_types::{CommonPrefix, DbCursorTrait, SimpleTable, Table};
7171
use crate::db::{DbTransaction, TableHandle, TransactionKind, RW};
7272
#[cfg(feature = "document_calls")]
7373
use crate::document_calls::{add_query, StorageQuery};
74+
use crate::metrics::STORAGE_APPEND_THIN_STATE_DIFF_LATENCY;
7475
use crate::mmap_file::LocationInFile;
7576
use crate::state::data::IndexedDeprecatedContractClass;
7677
use crate::{
@@ -431,7 +432,7 @@ impl<'env, Mode: TransactionKind> StateReader<'env, Mode> {
431432
}
432433

433434
impl StateStorageWriter for StorageTxn<'_, RW> {
434-
#[latency_histogram("storage_append_thin_state_diff_latency_seconds", false)]
435+
#[sequencer_latency_histogram(STORAGE_APPEND_THIN_STATE_DIFF_LATENCY, false)]
435436
fn append_state_diff(
436437
self,
437438
block_number: BlockNumber,

0 commit comments

Comments
 (0)