aboutsummaryrefslogtreecommitdiff
path: root/src/table/metrics.rs
blob: 38e93904383fe1f6d1f4d30aec6d14cf17104f5d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
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(),
		}
	}
}