From 70f58ccd1d829a9ee0a9b96add22dcd39061ebc7 Mon Sep 17 00:00:00 2001 From: or-shachar Date: Mon, 30 Aug 2021 15:20:01 +0300 Subject: [PATCH] Added duration in seconds as logger attribute Signed-off-by: or-shachar --- controllers/helmrelease_controller.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/controllers/helmrelease_controller.go b/controllers/helmrelease_controller.go index 6e2a47ffc..888688475 100644 --- a/controllers/helmrelease_controller.go +++ b/controllers/helmrelease_controller.go @@ -171,11 +171,13 @@ func (r *HelmReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request) // Record ready status r.recordReadiness(ctx, hr) + duration := time.Now().Sub(start) // Log reconciliation duration - durationMsg := fmt.Sprintf("reconcilation finished in %s", time.Now().Sub(start).String()) + durationMsg := fmt.Sprintf("reconcilation finished in %s", duration.String()) if result.RequeueAfter > 0 { durationMsg = fmt.Sprintf("%s, next run in %s", durationMsg, result.RequeueAfter.String()) } + log.WithValues("durationSeconds", duration.Seconds()) log.Info(durationMsg) return result, err