@@ -16,6 +16,7 @@ import (
1616
1717 "github.com/bombsimon/logrusr/v2"
1818 workspacev1 "github.com/gitpod-io/gitpod/ws-manager/api/crd/v1"
19+ "github.com/prometheus/client_golang/prometheus"
1920 "github.com/spf13/cobra"
2021 corev1 "k8s.io/api/core/v1"
2122 "k8s.io/apimachinery/pkg/api/errors"
@@ -143,6 +144,8 @@ var runCmd = &cobra.Command{
143144
144145 metrics .Registry .MustRegister (NodeLabelerCounterVec )
145146 metrics .Registry .MustRegister (NodeLabelerTimeHistVec )
147+ metrics .Registry .MustRegister (NodeScaledownAnnotationReconcileDuration )
148+ metrics .Registry .MustRegister (NodeScaledownAnnotationReconciliationQueueSize )
146149
147150 err = mgr .AddHealthzCheck ("healthz" , healthz .Ping )
148151 if err != nil {
@@ -356,6 +359,7 @@ func (c *NodeScaledownAnnotationController) workspaceFilter() predicate.Predicat
356359 default :
357360 log .WithField ("node" , ws .Status .Runtime .NodeName ).Warn ("reconciliation queue full" )
358361 }
362+ NodeScaledownAnnotationReconciliationQueueSize .Set (float64 (len (c .nodesToReconcile )))
359363 return true
360364 }
361365 return false
@@ -402,6 +406,9 @@ func (wc *NodeScaledownAnnotationController) Stop() {
402406
403407// reconcileAllNodes lists all nodes and reconciles each one
404408func (wc * NodeScaledownAnnotationController ) reconcileAllNodes (ctx context.Context ) (ctrl.Result , error ) {
409+ timer := prometheus .NewTimer (NodeScaledownAnnotationReconcileDuration .WithLabelValues ("all_nodes" ))
410+ defer timer .ObserveDuration ()
411+
405412 var nodes corev1.NodeList
406413 if err := wc .List (ctx , & nodes ); err != nil {
407414 log .WithError (err ).Error ("failed to list nodes" )
@@ -420,6 +427,9 @@ func (wc *NodeScaledownAnnotationController) reconcileAllNodes(ctx context.Conte
420427
421428// reconcileNode counts the workspaces running on a node and updates the autoscaler annotation accordingly
422429func (c * NodeScaledownAnnotationController ) reconcileNode (ctx context.Context , nodeName string ) error {
430+ timer := prometheus .NewTimer (NodeScaledownAnnotationReconcileDuration .WithLabelValues ("node" ))
431+ defer timer .ObserveDuration ()
432+
423433 var workspaceList workspacev1.WorkspaceList
424434 if err := c .List (ctx , & workspaceList , client.MatchingFields {
425435 "status.runtime.nodeName" : nodeName ,
0 commit comments