diff options
author | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-08-15 14:32:01 +0200 |
---|---|---|
committer | Quentin Dufour <quentin@deuxfleurs.fr> | 2024-08-15 14:32:01 +0200 |
commit | 1685d83c04f569ed66e706f3a548c20e9eb423b8 (patch) | |
tree | a2a33dcabf8afc06e1c2691508eb9ae2dcf02f64 | |
parent | 9d01a9870ca35e5d768d37bf058fb932f698c89b (diff) | |
download | garage-1685d83c04f569ed66e706f3a548c20e9eb423b8.tar.gz garage-1685d83c04f569ed66e706f3a548c20e9eb423b8.zip |
switch from sec to us
-rw-r--r-- | src/db/metric_proxy.rs | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/db/metric_proxy.rs b/src/db/metric_proxy.rs index 0449620a..c0856a57 100644 --- a/src/db/metric_proxy.rs +++ b/src/db/metric_proxy.rs @@ -9,7 +9,7 @@ use crate::{ }; use opentelemetry::{ global, - metrics::{Counter, ValueRecorder}, + metrics::{Counter, Unit, ValueRecorder}, KeyValue, }; @@ -32,6 +32,7 @@ impl MetricDbProxy { op_duration: meter .f64_value_recorder("db.op_duration") .with_description("Duration of operations on the local metadata engine") + .with_unit(Unit::new("us")) .init(), }; Db(Arc::new(s)) @@ -53,12 +54,12 @@ impl MetricDbProxy { let request_start = Instant::now(); let res = fx(); - self.op_duration.record( - Instant::now() - .saturating_duration_since(request_start) - .as_secs_f64(), - &metric_tags, - ); + let delay_nanos = Instant::now() + .saturating_duration_since(request_start) + .as_nanos(); + let delay_micro: f64 = delay_nanos as f64 / 1000.0f64; + println!("delay {}", delay_micro); + self.op_duration.record(delay_micro, &metric_tags); res } |