mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-21 10:51:29 +00:00
Merge pull request #96435 from Jiawei0227/master
Bug Fix for process_start_time_metric initialization
This commit is contained in:
commit
5cfce4e5cb
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user