fix(observability): refresh metric timestamps on each loop iteration

Move clock initialization inside processing loops to ensure exported metrics reflect the current time rather than a stale timestamp.
This commit is contained in:
Nils Andreas Svee committed 2026-04-13 16:32:30 +07:00
1 parent dd8735f46e
commit 530a715bdf
3 files changed
+6 -8

No files matched your search

+2 -3
View File
@@ -59,10 +59,9 @@ pub trait PingListener {
) -> anyhow::Result<()> {
let socket = &mut open_socket(type_)?;
// We need a realtime clock when exporting metrics
let clock = Time::new(ClockId::Realtime);
loop {
// Capture current time at the start of each iteration for metric timestamps
let clock = Time::new(ClockId::Realtime);
let (pkt, sender) = match socket.rcv_from() {
Ok(val) => val,
Err(_) => continue,