forked from Deuxfleurs/garage
Added system_metrics.rs file.
This commit is contained in:
parent
02e8eb167e
commit
aac348fe93
2 changed files with 35 additions and 0 deletions
|
@ -17,3 +17,5 @@ mod metrics;
|
|||
pub mod rpc_helper;
|
||||
|
||||
pub use rpc_helper::*;
|
||||
|
||||
pub mod system_metrics;
|
||||
|
|
33
src/rpc/system_metrics.rs
Normal file
33
src/rpc/system_metrics.rs
Normal file
|
@ -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(),
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue