Merge pull request #96435 from Jiawei0227/master

Bug Fix for process_start_time_metric initialization
This commit is contained in:
Kubernetes Prow Robot 2020-11-12 11:22:15 -08:00 committed by GitHub
commit 5cfce4e5cb
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -43,6 +43,12 @@ func RegisterProcessStartTime(registrationFunc func(Registerable) error) error {
klog.Errorf("Could not get process start time, %v", err)
start = float64(time.Now().Unix())
}
// processStartTime is a lazy metric which only get initialized after registered.
// so we have to explicitly create it before setting the label value. Otherwise
// it is a noop.
if !processStartTime.IsCreated() {
processStartTime.initializeMetric()
}
processStartTime.WithLabelValues().Set(start)
return registrationFunc(processStartTime)
}