Skip to content

Commit

Permalink
feat: Add golang metrics to argo-events metrics registry. (#2557)
Browse files Browse the repository at this point in the history
Signed-off-by: Antonio Si <[email protected]>
Co-authored-by: Antonio Si <[email protected]>
  • Loading branch information
antoniosi and antoniotsi authored Apr 6, 2023
1 parent f5ad05c commit 9dab78b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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))
Expand Down

0 comments on commit 9dab78b

Please sign in to comment.