From aac348fe937442bcf750316d6ebd47936d86ed90 Mon Sep 17 00:00:00 2001 From: Jonathan Davies Date: Mon, 9 Jan 2023 17:13:41 +0000 Subject: Added system_metrics.rs file. --- src/rpc/system_metrics.rs | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 src/rpc/system_metrics.rs (limited to 'src/rpc/system_metrics.rs') diff --git a/src/rpc/system_metrics.rs b/src/rpc/system_metrics.rs new file mode 100644 index 00000000..d96b67e4 --- /dev/null +++ b/src/rpc/system_metrics.rs @@ -0,0 +1,33 @@ +use opentelemetry::{global, metrics::*, KeyValue}; + +/// TableMetrics reference all counter used for metrics +pub struct SystemMetrics { + pub(crate) _garage_build_info: ValueObserver, + pub(crate) _replication_factor: ValueObserver, +} + +impl SystemMetrics { + pub fn new(replication_factor: usize) -> Self { + let meter = global::meter("garage_system"); + Self { + _garage_build_info: meter + .u64_value_observer("garage_build_info", move |observer| { + observer.observe( + 1, + &[KeyValue::new( + "version", + garage_util::version::garage_version(), + )], + ) + }) + .with_description("Garage build info") + .init(), + _replication_factor: meter + .u64_value_observer("garage_replication_factor", move |observer| { + observer.observe(replication_factor as u64, &[]) + }) + .with_description("Garage replication factor setting") + .init(), + } + } +} -- cgit v1.2.3