You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Replace scattered wall-clock timestamp calls (system_clock::now(),
GetCurrentTimeInMicroseconds(), ms_since_epoch()) with a single
current_timestamp_ns() utility that anchors to epoch time at process
start and uses uv_hrtime() for elapsed time.
Benefits:
- Monotonicity: timestamps never jump backward due to NTP adjustments,
VM migrations, or manual clock changes
- Consistency: all metrics, traces, and agent protocol messages use
the same time source
- Precision: nanosecond resolution from uv_hrtime()
- Performance: uv_hrtime() uses vDSO-accelerated clock_gettime() on
Linux, avoiding syscall overhead on each timestamp
The approach trusts the system clock once at startup, then relies on
the monotonic high-resolution timer. This is preferable for
observability data where ordering and rate calculations matter more
than tracking real-time clock drift.
Refactored current_timestamp_ns() to cache the offset between epoch
and hrtime at startup, reducing per-call overhead to a single addition.
0 commit comments