mirror of
https://forgejo.ellis.link/continuwuation/continuwuity.git
synced 2026-11-14 20:56:49 +00:00
fix(metrics): Address review feedback
This commit is contained in:
1 parent
9d454fd883
commit
ea3ec965ed
9 files changed
+98
-81
No files matched your search
@@ -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();
|
||||
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user