pub fn find_metric_u64(metrics: &PayloadMetrics, key: &str) -> Option<u64>Expand description
Fetch a metric by exact name and return its numeric value as a
u64. Returns None if the metric is absent. Thin wrapper
around find_metric + value as u64 for the common
numeric-lookup shape.
§f64 → u64 precision
JSON numbers parse into the probe’s flat-metric list as f64
(serde_json’s number type). Integer values round-trip through
f64 without precision loss only up to 2^53
(9_007_199_254_740_992); above that bound, adjacent u64
values collapse onto the same f64 and value as u64 loses
the low-order bits. The probe’s emitted counters
(allocated_bytes, deallocated_bytes, tid numbers, snapshot
timestamps in seconds) are in practice far below this
threshold on realistic workloads: a 64-bit byte counter would
require >8 PiB of total-allocated memory, and Linux pids are
capped at 2^22. The bound is therefore a soft invariant —
consumers should NOT feed arbitrary externally-controlled
values through this helper without a prior range check.
A debug_assert! on the same bound catches the invariant
locally so a future metric that genuinely exceeds 2^53 lights
up in a debug build before the truncation silently corrupts a
downstream comparison; release builds trust the soft invariant
and perform the as u64 cast unconditionally.