From 93aed736dbac89ab1b16c29b9d73706d26bb36f4 Mon Sep 17 00:00:00 2001 From: shreddedbacon Date: Wed, 7 Feb 2024 11:55:16 +1100 Subject: [PATCH] feat: add metrics for cli idling events --- handlers/idler/cli-kubernetes.go | 1 + handlers/idler/metrics.go | 8 ++++++-- handlers/idler/service-kubernetes.go | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/handlers/idler/cli-kubernetes.go b/handlers/idler/cli-kubernetes.go index 81c42d0..e05170a 100644 --- a/handlers/idler/cli-kubernetes.go +++ b/handlers/idler/cli-kubernetes.go @@ -136,6 +136,7 @@ func (h *Idler) kubernetesCLI(ctx context.Context, opLog logr.Logger, namespace } else { opLog.Info(fmt.Sprintf("Deployment %s scaled to 0", deployment.ObjectMeta.Name)) } + cliIdleEvents.Inc() } else { opLog.Info(fmt.Sprintf("Deployment %s would be scaled to 0", deployment.ObjectMeta.Name)) } diff --git a/handlers/idler/metrics.go b/handlers/idler/metrics.go index 9b74a17..badc88a 100644 --- a/handlers/idler/metrics.go +++ b/handlers/idler/metrics.go @@ -6,8 +6,12 @@ import ( ) var ( - idleEvents = promauto.NewCounter(prometheus.CounterOpts{ + serviceIdleEvents = promauto.NewCounter(prometheus.CounterOpts{ Name: "aergia_idling_events", - Help: "The total number of events that aergia has processed to idle environments", + Help: "The total number of service idling events that aergia has processed to idle environments", + }) + cliIdleEvents = promauto.NewCounter(prometheus.CounterOpts{ + Name: "aergia_cli_idling_events", + Help: "The total number of cli idling events that aergia has processed to idle environments", }) ) diff --git a/handlers/idler/service-kubernetes.go b/handlers/idler/service-kubernetes.go index 2c416bf..dec18f0 100644 --- a/handlers/idler/service-kubernetes.go +++ b/handlers/idler/service-kubernetes.go @@ -276,7 +276,7 @@ func (h *Idler) patchIngress(ctx context.Context, opLog logr.Logger, namespace c }, }, }) - idleEvents.Inc() + serviceIdleEvents.Inc() if err := h.Client.Patch(ctx, namespaceCopy, client.RawPatch(types.MergePatchType, mergePatch)); err != nil { return fmt.Errorf(fmt.Sprintf("Error patching namespace %s", namespace.Name)) }