diff options
author | Alex <alex@adnab.me> | 2023-01-02 12:42:24 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-01-02 12:42:24 +0000 |
commit | 7f7d53cfa991054afcd2940cc43a4d7f1a6668e7 (patch) | |
tree | 15c60c9ecf583532eaf62d492beb63bd8ae7e3b2 /src/table/metrics.rs | |
parent | 1af4a5ed569e42f77dd4ecc9364a27f7ed43df63 (diff) | |
parent | d1279e04f3550eae2eb5e0f25efbdf69b42fbeb9 (diff) | |
download | garage-7f7d53cfa991054afcd2940cc43a4d7f1a6668e7.tar.gz garage-7f7d53cfa991054afcd2940cc43a4d7f1a6668e7.zip |
Merge pull request 'improvements to CLI and new debug features' (#448) from cli-improvements into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/448
Diffstat (limited to 'src/table/metrics.rs')
-rw-r--r-- | src/table/metrics.rs | 38 |
1 files changed, 37 insertions, 1 deletions
diff --git a/src/table/metrics.rs b/src/table/metrics.rs index 3a1783e0..8318a84f 100644 --- a/src/table/metrics.rs +++ b/src/table/metrics.rs @@ -5,6 +5,8 @@ use garage_db::counted_tree_hack::CountedTree; /// TableMetrics reference all counter used for metrics pub struct TableMetrics { + pub(crate) _table_size: ValueObserver<u64>, + pub(crate) _merkle_tree_size: ValueObserver<u64>, pub(crate) _merkle_todo_len: ValueObserver<u64>, pub(crate) _gc_todo_len: ValueObserver<u64>, @@ -20,9 +22,43 @@ pub struct TableMetrics { pub(crate) sync_items_received: Counter<u64>, } impl TableMetrics { - pub fn new(table_name: &'static str, merkle_todo: db::Tree, gc_todo: CountedTree) -> Self { + pub fn new( + table_name: &'static str, + store: db::Tree, + merkle_tree: db::Tree, + merkle_todo: db::Tree, + gc_todo: CountedTree, + ) -> Self { let meter = global::meter(table_name); TableMetrics { + _table_size: meter + .u64_value_observer( + "table.size", + move |observer| { + if let Ok(Some(v)) = store.fast_len() { + observer.observe( + v as u64, + &[KeyValue::new("table_name", table_name)], + ); + } + }, + ) + .with_description("Number of items in table") + .init(), + _merkle_tree_size: meter + .u64_value_observer( + "table.merkle_tree_size", + move |observer| { + if let Ok(Some(v)) = merkle_tree.fast_len() { + observer.observe( + v as u64, + &[KeyValue::new("table_name", table_name)], + ); + } + }, + ) + .with_description("Number of nodes in table's Merkle tree") + .init(), _merkle_todo_len: meter .u64_value_observer( "table.merkle_updater_todo_queue_length", |