From 9dab78bd29241c5ee40495fb34c37d7ff1bc7bf2 Mon Sep 17 00:00:00 2001 From: antoniosi Date: Thu, 6 Apr 2023 15:53:38 -0700 Subject: [PATCH] feat: Add golang metrics to argo-events metrics registry. (#2557) Signed-off-by: Antonio Si Co-authored-by: Antonio Si --- metrics/metrics.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index edb2a96f9d..1b24e29959 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -4,6 +4,8 @@ import ( "context" "net/http" + "github.com/prometheus/client_golang/prometheus/collectors" + "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promhttp" "go.uber.org/zap" @@ -167,8 +169,9 @@ func (m *Metrics) ActionDuration(sensorName, triggerName string, num float64) { func (m *Metrics) Run(ctx context.Context, addr string) { log := logging.FromContext(ctx) metricsRegistry := prometheus.NewRegistry() - metricsRegistry.MustRegister(m) + metricsRegistry.MustRegister(collectors.NewGoCollector(), m) http.Handle("/metrics", promhttp.HandlerFor(metricsRegistry, promhttp.HandlerOpts{})) + log.Info("starting metrics server") if err := http.ListenAndServe(addr, nil); err != nil { log.Fatalw("failed to start metrics server", zap.Error(err))