mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-20 10:20:51 +00:00
Merge pull request #113325 from panslava/fix-time-since-defer
Fix time.Since() in defer. Wrap in anonymous function
This commit is contained in:
commit
449c46258b
@ -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 {
|
||||
|
@ -101,7 +101,10 @@ func getBaseEnv() (*cel.Env, error) {
|
||||
// perCallLimit was added for testing purpose only. Callers should always use const PerCallLimit as input.
|
||||
func Compile(s *schema.Structural, declType *apiservercel.DeclType, perCallLimit uint64) ([]CompilationResult, error) {
|
||||
t := time.Now()
|
||||
defer metrics.Metrics.ObserveCompilation(time.Since(t))
|
||||
defer func() {
|
||||
metrics.Metrics.ObserveCompilation(time.Since(t))
|
||||
}()
|
||||
|
||||
if len(s.Extensions.XValidations) == 0 {
|
||||
return nil, nil
|
||||
}
|
||||
|
@ -139,7 +139,9 @@ func validator(s *schema.Structural, isResourceRoot bool, declType *cel.DeclType
|
||||
// context is passed for supporting context cancellation during cel validation
|
||||
func (s *Validator) Validate(ctx context.Context, fldPath *field.Path, sts *schema.Structural, obj, oldObj interface{}, costBudget int64) (errs field.ErrorList, remainingBudget int64) {
|
||||
t := time.Now()
|
||||
defer metrics.Metrics.ObserveEvaluation(time.Since(t))
|
||||
defer func() {
|
||||
metrics.Metrics.ObserveEvaluation(time.Since(t))
|
||||
}()
|
||||
remainingBudget = costBudget
|
||||
if s == nil || obj == nil {
|
||||
return nil, remainingBudget
|
||||
|
Loading…
Reference in New Issue
Block a user