Files
kubernetes/pkg/scheduler/framework/runtime
Damien Grisonnet cb79675508 Fix defer duration metric recording bug
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
2026-02-06 00:29:15 +08:00
..