Skip to content

Commit

Permalink
feat: add metrics for cli idling events
Browse files Browse the repository at this point in the history
  • Loading branch information
shreddedbacon committed Feb 7, 2024
1 parent 76095b0 commit 93aed73
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
1 change: 1 addition & 0 deletions handlers/idler/cli-kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down
8 changes: 6 additions & 2 deletions handlers/idler/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
})
)
2 changes: 1 addition & 1 deletion handlers/idler/service-kubernetes.go
Original file line number Diff line number Diff line change
Expand Up @@ -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))
}
Expand Down

0 comments on commit 93aed73

Please sign in to comment.