fix(metrics): Address review feedback

This commit is contained in:
Erwan Leboucher authored and Jade Ellis committed 2026-10-12 10:03:15 +01:00
1 parent 9d454fd883
commit ea3ec965ed
9 files changed
+98 -81

No files matched your search

+3 -4
View File
@@ -1,4 +1,4 @@
use std::time::{Duration, SystemTime};
use std::time::{Duration, Instant};
use opentelemetry::{
KeyValue,
@@ -133,14 +133,13 @@ pub fn duration_buckets() -> Vec<f64> { (0..16).map(|i| 0.001 * f64::from(1_u32
fn size_buckets() -> Vec<f64> { (0..11).map(|i| 1024.0 * f64::from(4_u32.pow(i))).collect() }
fn register_process(meter: &Meter) {
let started = SystemTime::now();
let started = Instant::now();
meter
.f64_observable_gauge(metric::PROCESS_UPTIME)
.with_description("Time since the server started")
.with_unit("s")
.with_callback(move |observer| {
let uptime = started.elapsed().unwrap_or_default();
observer.observe(uptime.as_secs_f64(), &[]);
observer.observe(started.elapsed().as_secs_f64(), &[]);
})
.build();
+5 -1
View File
@@ -35,7 +35,11 @@ pub(super) fn memory() -> Option<(u64, u64)> { None }
#[cfg(target_os = "linux")]
pub(super) fn open_fds() -> Option<u64> {
let count = std::fs::read_dir("/proc/self/fd").ok()?.count();
// The directory handle used for the listing is itself an open descriptor.
let count = std::fs::read_dir("/proc/self/fd")
.ok()?
.count()
.checked_sub(1)?;
count.try_into().ok()
}