diff options
author | Alex Auvolat <alex@adnab.me> | 2022-12-13 15:54:03 +0100 |
---|---|---|
committer | Alex Auvolat <alex@adnab.me> | 2022-12-13 15:54:03 +0100 |
commit | 041b60ed1dc48563ad297a6a30230655555c9a20 (patch) | |
tree | 3dfa2f0d429d7330bcadc57d7fbaad2317858279 /src/block/metrics.rs | |
parent | f8d5409894d09903588cf3e9ae5ab64aab55d749 (diff) | |
download | garage-041b60ed1dc48563ad297a6a30230655555c9a20.tar.gz garage-041b60ed1dc48563ad297a6a30230655555c9a20.zip |
Add block.rc_size, table.size and table.merkle_tree_size metrics
Diffstat (limited to 'src/block/metrics.rs')
-rw-r--r-- | src/block/metrics.rs | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/block/metrics.rs b/src/block/metrics.rs index 477add66..fbef95af 100644 --- a/src/block/metrics.rs +++ b/src/block/metrics.rs @@ -1,9 +1,11 @@ use opentelemetry::{global, metrics::*}; +use garage_db as db; use garage_db::counted_tree_hack::CountedTree; /// TableMetrics reference all counter used for metrics pub struct BlockManagerMetrics { + pub(crate) _rc_size: ValueObserver<u64>, pub(crate) _resync_queue_len: ValueObserver<u64>, pub(crate) _resync_errored_blocks: ValueObserver<u64>, @@ -23,9 +25,17 @@ pub struct BlockManagerMetrics { } impl BlockManagerMetrics { - pub fn new(resync_queue: CountedTree, resync_errors: CountedTree) -> Self { + pub fn new(rc_tree: db::Tree, resync_queue: CountedTree, resync_errors: CountedTree) -> Self { let meter = global::meter("garage_model/block"); Self { + _rc_size: meter + .u64_value_observer("block.rc_size", move |observer| { + if let Ok(Some(v)) = rc_tree.fast_len() { + observer.observe(v as u64, &[]) + } + }) + .with_description("Number of blocks known to the reference counter") + .init(), _resync_queue_len: meter .u64_value_observer("block.resync_queue_length", move |observer| { observer.observe(resync_queue.len() as u64, &[]) |