diff options
author | Alex <alex@adnab.me> | 2023-01-11 16:00:31 +0000 |
---|---|---|
committer | Alex <alex@adnab.me> | 2023-01-11 16:00:31 +0000 |
commit | be6b8f419d71640e64bccfe195a573daeeab2263 (patch) | |
tree | 7274359a6c9203ad711287c0e98a23b0001bc570 /src/rpc/system_metrics.rs | |
parent | 02e8eb167efa1f08d69fe7f8e6192cde726c45aa (diff) | |
parent | 4cfb469d2bcce5bd41fe0af0022b34716ac7279a (diff) | |
download | garage-be6b8f419d71640e64bccfe195a573daeeab2263.tar.gz garage-be6b8f419d71640e64bccfe195a573daeeab2263.zip |
Merge pull request 'Implemented system metrics' (#472) from jpds/garage:system-metrics into main
Reviewed-on: https://git.deuxfleurs.fr/Deuxfleurs/garage/pulls/472
Reviewed-by: Alex <alex@adnab.me>
Diffstat (limited to 'src/rpc/system_metrics.rs')
-rw-r--r-- | src/rpc/system_metrics.rs | 33 |
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(), + } + } +} |