Merge pull request #113325 from panslava/fix-time-since-defer

Fix time.Since() in defer. Wrap in anonymous function
This commit is contained in:
Kubernetes Prow Robot
2022-10-25 06:42:36 -07:00
committed by GitHub
3 changed files with 10 additions and 3 deletions

View File

@@ -435,7 +435,9 @@ func (e *execPlugin) ExecPlugin(ctx context.Context, image string) (*credentialp
func (e *execPlugin) runPlugin(ctx context.Context, cmd *exec.Cmd, image string) error {
startTime := time.Now()
defer kubeletCredentialProviderPluginDuration.WithLabelValues(e.name).Observe(time.Since(startTime).Seconds())
defer func() {
kubeletCredentialProviderPluginDuration.WithLabelValues(e.name).Observe(time.Since(startTime).Seconds())
}()
err := cmd.Run()
if ctx.Err() != nil {