aboutsummaryrefslogtreecommitdiff
path: root/src/table/metrics.rs
diff options
context:
space:
mode:
authorMaximilien R <maximilien@deuxfleurs.fr>2022-02-15 20:09:43 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-14 10:51:17 +0100
commit1e2cf26373ef1812a3152a0057774f6381e66914 (patch)
tree1212796b28762f404f71702a59b5384e69bc4e87 /src/table/metrics.rs
parente349af13a7268d567c1bacc819af5b89c2d4231f (diff)
downloadgarage-1e2cf26373ef1812a3152a0057774f6381e66914.tar.gz
garage-1e2cf26373ef1812a3152a0057774f6381e66914.zip
Implement basic metrics in table
Diffstat (limited to 'src/table/metrics.rs')
-rw-r--r--src/table/metrics.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/table/metrics.rs b/src/table/metrics.rs
new file mode 100644
index 00000000..38e93904
--- /dev/null
+++ b/src/table/metrics.rs
@@ -0,0 +1,25 @@
+use opentelemetry::{global, metrics::*, KeyValue};
+
+/// TableMetrics reference all counter used for metrics
+pub struct TableMetrics {
+ merkle_updater_todo_queue_length: ValueObserver<u64>,
+}
+impl TableMetrics {
+ pub fn new(table_name: &'static str, merkle_todo: sled::Tree) -> Self {
+ let meter = global::meter(table_name);
+ TableMetrics {
+ merkle_updater_todo_queue_length: meter
+ .u64_value_observer(
+ format!("merkle_updater_todo_queue_length"),
+ move |observer| {
+ observer.observe(
+ merkle_todo.len() as u64,
+ &[KeyValue::new("table_name", table_name)],
+ )
+ },
+ )
+ .with_description("Bucket merkle updater TODO queue length")
+ .init(),
+ }
+ }
+}