aboutsummaryrefslogtreecommitdiff
path: root/src/rpc/metrics.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-02-16 14:23:04 +0100
committerAlex Auvolat <alex@adnab.me>2022-03-14 10:51:50 +0100
commit2cab84b1fe423a41b356211e592a614c95ec4e0c (patch)
treec7dc3227feccbd6f4a8aba0bf8025201f3acc229 /src/rpc/metrics.rs
parent1e2cf26373ef1812a3152a0057774f6381e66914 (diff)
downloadgarage-2cab84b1fe423a41b356211e592a614c95ec4e0c.tar.gz
garage-2cab84b1fe423a41b356211e592a614c95ec4e0c.zip
Add many metrics in table/ and rpc/
Diffstat (limited to 'src/rpc/metrics.rs')
-rw-r--r--src/rpc/metrics.rs55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/rpc/metrics.rs b/src/rpc/metrics.rs
new file mode 100644
index 00000000..c900518c
--- /dev/null
+++ b/src/rpc/metrics.rs
@@ -0,0 +1,55 @@
+use std::sync::Arc;
+
+use opentelemetry::{global, metrics::*};
+use tokio::sync::Semaphore;
+
+/// TableMetrics reference all counter used for metrics
+pub struct RpcMetrics {
+ pub(crate) _rpc_available_permits: ValueObserver<u64>,
+
+ pub(crate) rpc_counter: Counter<u64>,
+ pub(crate) rpc_timeout_counter: Counter<u64>,
+ pub(crate) rpc_netapp_error_counter: Counter<u64>,
+ pub(crate) rpc_garage_error_counter: Counter<u64>,
+
+ pub(crate) rpc_duration: ValueRecorder<f64>,
+ pub(crate) rpc_queueing_time: ValueRecorder<f64>,
+}
+impl RpcMetrics {
+ pub fn new(sem: Arc<Semaphore>) -> Self {
+ let meter = global::meter("garage_rpc");
+ RpcMetrics {
+ _rpc_available_permits: meter
+ .u64_value_observer("rpc.available_permits", move |observer| {
+ observer.observe(sem.available_permits() as u64, &[])
+ })
+ .with_description("Number of available RPC permits")
+ .init(),
+
+ rpc_counter: meter
+ .u64_counter("rpc.request_counter")
+ .with_description("Number of RPC requests emitted")
+ .init(),
+ rpc_timeout_counter: meter
+ .u64_counter("rpc.timeout_counter")
+ .with_description("Number of RPC timeouts")
+ .init(),
+ rpc_netapp_error_counter: meter
+ .u64_counter("rpc.netapp_error_counter")
+ .with_description("Number of communication errors (errors in the Netapp library)")
+ .init(),
+ rpc_garage_error_counter: meter
+ .u64_counter("rpc.garage_error_counter")
+ .with_description("Number of RPC errors (errors happening when handling the RPC)")
+ .init(),
+ rpc_duration: meter
+ .f64_value_recorder("rpc.duration")
+ .with_description("Duration of RPCs")
+ .init(),
+ rpc_queueing_time: meter
+ .f64_value_recorder("rpc.queueing_time")
+ .with_description("Time RPC requests were queued for before being sent")
+ .init(),
+ }
+ }
+}