-
Notifications
You must be signed in to change notification settings - Fork 29
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(papyrus_storage)!: delte dump_declared_classes utils (#2350)
- Loading branch information
1 parent
0321278
commit f9a0fb1
Showing
10 changed files
with
78 additions
and
366 deletions.
There are no files selected for viewing
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 was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
//! module for metrics utilities. | ||
#[cfg(test)] | ||
#[path = "storage_metrics_test.rs"] | ||
mod storage_metrics_test; | ||
|
||
use metrics::{absolute_counter, gauge}; | ||
use tracing::debug; | ||
|
||
use crate::{StorageReader, StorageResult}; | ||
|
||
// TODO(dvir): add storage metrics names to this module. | ||
|
||
// TODO(dvir): consider adding storage size metrics. | ||
// TODO(dvir): relocate all the storage metrics in one module and export them (also in other | ||
// crates). | ||
/// Updates storage metrics about the state of the storage. | ||
#[allow(clippy::as_conversions)] | ||
pub fn update_storage_metrics(reader: &StorageReader) -> StorageResult<()> { | ||
debug!("updating storage metrics"); | ||
gauge!("storage_free_pages_number", reader.db_reader.get_free_pages()? as f64); | ||
let info = reader.db_reader.get_db_info()?; | ||
absolute_counter!( | ||
"storage_last_page_number", | ||
u64::try_from(info.last_pgno()).expect("usize should fit in u64") | ||
); | ||
absolute_counter!( | ||
"storage_last_transaction_index", | ||
u64::try_from(info.last_txnid()).expect("usize should fit in u64") | ||
); | ||
Ok(()) | ||
} |
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,44 @@ | ||
use metrics_exporter_prometheus::PrometheusBuilder; | ||
use papyrus_test_utils::prometheus_is_contained; | ||
use prometheus_parse::Value::{Counter, Gauge}; | ||
|
||
use super::update_storage_metrics; | ||
use crate::test_utils::get_test_storage; | ||
|
||
#[test] | ||
fn update_storage_metrics_test() { | ||
let ((reader, _writer), _temp_dir) = get_test_storage(); | ||
let handle = PrometheusBuilder::new().install_recorder().unwrap(); | ||
|
||
assert!(prometheus_is_contained(handle.render(), "storage_free_pages_number", &[]).is_none()); | ||
assert!(prometheus_is_contained(handle.render(), "storage_last_page_number", &[]).is_none()); | ||
assert!( | ||
prometheus_is_contained(handle.render(), "storage_last_transaction_index", &[]).is_none() | ||
); | ||
|
||
update_storage_metrics(&reader).unwrap(); | ||
|
||
let Gauge(free_pages) = | ||
prometheus_is_contained(handle.render(), "storage_free_pages_number", &[]).unwrap() | ||
else { | ||
panic!("storage_free_pages_number is not a Gauge") | ||
}; | ||
// TODO(dvir): add an upper limit when the bug in the binding freelist function will be fixed. | ||
assert!(0f64 < free_pages); | ||
|
||
let Counter(last_page) = | ||
prometheus_is_contained(handle.render(), "storage_last_page_number", &[]).unwrap() | ||
else { | ||
panic!("storage_last_page_number is not a Counter") | ||
}; | ||
assert!(0f64 < last_page); | ||
assert!(last_page < 1000f64); | ||
|
||
let Counter(last_transaction) = | ||
prometheus_is_contained(handle.render(), "storage_last_transaction_index", &[]).unwrap() | ||
else { | ||
panic!("storage_last_transaction_index is not a Counter") | ||
}; | ||
assert!(0f64 < last_transaction); | ||
assert!(last_transaction < 100f64); | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.