mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-18 04:54:54 +00:00
Defer statements were incorrectly recording near-zero duration values (~2 microseconds) instead of actual elapsed time because arguments to deferred functions are evaluated immediately when the defer statement is executed. Solution: Added HistogramVec.ObserveSince() API that properly handles deferred duration measurement, and replaced all problematic patterns. The new API pattern: defer metric.ObserveSince(time.Now(), labels)() Also deprecated SinceInSeconds() with warnings about incorrect defer usage. Fixes: Incorrect HTTP request duration metrics in kubelet