From d45e1a2f149133addc1dceb93e81f55320352563 Mon Sep 17 00:00:00 2001 From: Aditya Thebe Date: Wed, 5 Jun 2024 11:11:23 +0545 Subject: [PATCH] feat: add metrics for the number of resource & event watcher we have --- scrapers/kubernetes/events_watch.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/scrapers/kubernetes/events_watch.go b/scrapers/kubernetes/events_watch.go index 66a1b057..91bc9800 100644 --- a/scrapers/kubernetes/events_watch.go +++ b/scrapers/kubernetes/events_watch.go @@ -58,6 +58,7 @@ func getUnstructuredFromInformedObj(resource v1.KubernetesResourceToWatch, obj a // WatchResources watches Kubernetes resources func WatchResources(ctx api.ScrapeContext, config v1.Kubernetes) error { + buffer := make(chan *unstructured.Unstructured, ctx.DutyContext().Properties().Int("kubernetes.watch.resources.bufferSize", WatchResourceBufferSize)) WatchResourceBuffer.Store(config.Hash(), buffer) @@ -129,6 +130,7 @@ func WatchResources(ctx api.ScrapeContext, config v1.Kubernetes) error { go informer.Run(stopper) } + ctx.Counter("kubernetes_scraper_resource_watcher", lo.FromPtr(ctx.ScrapeConfig().GetPersistedID()).String()).Add(1) ctx.Logger.V(1).Infof("waiting for informers") wg.Wait() @@ -193,6 +195,7 @@ func WatchEvents(ctx api.ScrapeContext, config v1.Kubernetes) error { } defer watcher.Stop() + ctx.Counter("kubernetes_scraper_event_watcher", lo.FromPtr(ctx.ScrapeConfig().GetPersistedID()).String()).Add(1) for watchEvent := range watcher.ResultChan() { var event v1.KubernetesEvent if err := event.FromObj(watchEvent.Object); err != nil {