aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/system_metrics.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2023-01-11 17:09:37 +0100
committerAlex Auvolat <alex@adnab.me>2023-01-11 17:09:37 +0100
commitdac254a6e7413498df0e3b626769c2d2be3a4cfb (patch)
tree3eca3ebc2d0c1f9c2c5029e3197bcc925eeafcfd /src/rpc/system_metrics.rs
parent638c5a3ce006eba9d90a6358655ba2091423efd7 (diff)
parent94d723f27cea7aa58d11af3e18a165283b40f19a (diff)
downloadgarage-dac254a6e7413498df0e3b626769c2d2be3a4cfb.tar.gz
garage-dac254a6e7413498df0e3b626769c2d2be3a4cfb.zip
Merge branch 'main' into k2v-watch-range-2
Diffstat (limited to 'src/rpc/system_metrics.rs')
-rw-r--r--src/rpc/system_metrics.rs33
1 files changed, 33 insertions, 0 deletions
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<u64>,
+ pub(crate) _replication_factor: ValueObserver<u64>,
+}
+
+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(),
+ }
+ }
+}