aboutsummaryrefslogtreecommitdiff
path: root/src/table/metrics.rs
diff options
context:
space:
mode:
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(),
+ }
+ }
+}