aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonathan Davies <jpds@protonmail.com>2023-01-09 17:13:41 +0000
committerJonathan Davies <jpds@protonmail.com>2023-01-10 10:38:50 +0000
commitaac348fe937442bcf750316d6ebd47936d86ed90 (patch)
tree0b847ed2614a4d260602e590ec5ab535d49d5d9f
parent02e8eb167efa1f08d69fe7f8e6192cde726c45aa (diff)
downloadgarage-aac348fe937442bcf750316d6ebd47936d86ed90.tar.gz
garage-aac348fe937442bcf750316d6ebd47936d86ed90.zip
Added system_metrics.rs file.
-rw-r--r--src/rpc/lib.rs2
-rw-r--r--src/rpc/system_metrics.rs33
2 files changed, 35 insertions, 0 deletions
diff --git a/src/rpc/lib.rs b/src/rpc/lib.rs
index 86f63568..a8cc0030 100644
--- a/src/rpc/lib.rs
+++ b/src/rpc/lib.rs
@@ -17,3 +17,5 @@ mod metrics;
pub mod rpc_helper;
pub use rpc_helper::*;
+
+pub mod system_metrics;
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(),
+ }
+ }
+}