Skip to content

Commit

Permalink
controller: properly record object metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Hidde Beydals <hidde@hhh.computer>
  • Loading branch information
hiddeco committed Nov 3, 2023
1 parent 3f9ed3b commit 63e428a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions internal/controller/helmrelease_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,6 @@ func (r *HelmReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request)
return ctrl.Result{}, client.IgnoreNotFound(err)
}

defer func() {
// Always record metrics.
r.Metrics.RecordSuspend(ctx, obj, obj.Spec.Suspend)
r.Metrics.RecordReadiness(ctx, obj)
r.Metrics.RecordDuration(ctx, obj, start)
}()

// Initialize the patch helper with the current version of the object.
patchHelper := patch.NewSerialPatcher(obj, r.Client)

Expand All @@ -180,9 +173,10 @@ func (r *HelmReleaseReconciler) Reconcile(ctx context.Context, req ctrl.Request)
}
}

// Always record readiness and duration metrics.
defer r.Metrics.RecordDuration(ctx, obj, start)
defer r.Metrics.RecordReadiness(ctx, obj)
// Always record suspend, readiness and duration metrics.
r.Metrics.RecordSuspend(ctx, obj, obj.Spec.Suspend)
r.Metrics.RecordReadiness(ctx, obj)
r.Metrics.RecordDuration(ctx, obj, start)
}()

// Examine if the object is under deletion.
Expand Down

0 comments on commit 63e428a

Please sign in to comment.