fix: preserve timestamp precision of irate (#5904)

Signed-off-by: Ruihang Xia <waynestxia@gmail.com>
This commit is contained in:
Ruihang Xia
2025-04-15 23:00:30 +08:00
committed by GitHub
parent 799c7cbfa9
commit 0fb9e1995e
3 changed files with 89 additions and 3 deletions
+1 -3
View File
@@ -138,9 +138,7 @@ impl<const IS_RATE: bool> IDelta<IS_RATE> {
}
// else is rate
// TODO(ruihang): "divide 1000" converts the timestamp from millisecond to second.
// it should consider other percisions.
let sampled_interval = (timestamps[len - 1] - timestamps[len - 2]) / 1000;
let sampled_interval = (timestamps[len - 1] - timestamps[len - 2]) as f64 / 1000.0;
let last_value = values[len - 1];
let prev_value = values[len - 2];
let result_value = if last_value < prev_value {