forked from Deuxfleurs/garage
switch from sec to us
This commit is contained in:
parent
9d01a9870c
commit
1685d83c04
1 changed files with 8 additions and 7 deletions
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
};
|
};
|
||||||
use opentelemetry::{
|
use opentelemetry::{
|
||||||
global,
|
global,
|
||||||
metrics::{Counter, ValueRecorder},
|
metrics::{Counter, Unit, ValueRecorder},
|
||||||
KeyValue,
|
KeyValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -32,6 +32,7 @@ impl MetricDbProxy {
|
||||||
op_duration: meter
|
op_duration: meter
|
||||||
.f64_value_recorder("db.op_duration")
|
.f64_value_recorder("db.op_duration")
|
||||||
.with_description("Duration of operations on the local metadata engine")
|
.with_description("Duration of operations on the local metadata engine")
|
||||||
|
.with_unit(Unit::new("us"))
|
||||||
.init(),
|
.init(),
|
||||||
};
|
};
|
||||||
Db(Arc::new(s))
|
Db(Arc::new(s))
|
||||||
|
@ -53,12 +54,12 @@ impl MetricDbProxy {
|
||||||
|
|
||||||
let request_start = Instant::now();
|
let request_start = Instant::now();
|
||||||
let res = fx();
|
let res = fx();
|
||||||
self.op_duration.record(
|
let delay_nanos = Instant::now()
|
||||||
Instant::now()
|
.saturating_duration_since(request_start)
|
||||||
.saturating_duration_since(request_start)
|
.as_nanos();
|
||||||
.as_secs_f64(),
|
let delay_micro: f64 = delay_nanos as f64 / 1000.0f64;
|
||||||
&metric_tags,
|
println!("delay {}", delay_micro);
|
||||||
);
|
self.op_duration.record(delay_micro, &metric_tags);
|
||||||
|
|
||||||
res
|
res
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue