From 9bf1c04f038981f05137dec8428075e48c8ddf7b Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Thu, 23 Mar 2023 13:41:35 +0100 Subject: [PATCH 1/2] Adds all go metrics to Prometheus instrumentation --- pkg/phlare/modules.go | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/pkg/phlare/modules.go b/pkg/phlare/modules.go index 77a5b54bf..127ffb029 100644 --- a/pkg/phlare/modules.go +++ b/pkg/phlare/modules.go @@ -18,6 +18,7 @@ import ( grpcgw "github.com/grpc-ecosystem/grpc-gateway/v2/runtime" "github.com/pkg/errors" "github.com/prometheus/client_golang/prometheus" + "github.com/prometheus/client_golang/prometheus/collectors" "github.com/prometheus/common/version" "github.com/thanos-io/thanos/pkg/discovery/dns" "github.com/weaveworks/common/middleware" @@ -372,7 +373,13 @@ func (f *Phlare) initIngester() (_ services.Service, err error) { } func (f *Phlare) initServer() (services.Service, error) { - prometheus.MustRegister(version.NewCollector("phlare")) + f.reg.MustRegister(version.NewCollector("phlare")) + f.reg.Unregister(collectors.NewGoCollector()) + // register collector with additional metrics + f.reg.MustRegister(collectors.NewGoCollector( + collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll), + )) + prometheus.MustRegister() DisableSignalHandling(&f.Cfg.Server) f.Cfg.Server.Registerer = prometheus.WrapRegistererWithPrefix("phlare_", f.reg) // Not all default middleware works with http2 so we'll add then manually. From c8aa93906bb1a1f79a849ca368247fd7875c067e Mon Sep 17 00:00:00 2001 From: Cyril Tovena Date: Thu, 23 Mar 2023 13:42:26 +0100 Subject: [PATCH 2/2] Adds all go metrics to Prometheus instrumentation --- pkg/phlare/modules.go | 1 - 1 file changed, 1 deletion(-) diff --git a/pkg/phlare/modules.go b/pkg/phlare/modules.go index 127ffb029..e3b1c155b 100644 --- a/pkg/phlare/modules.go +++ b/pkg/phlare/modules.go @@ -379,7 +379,6 @@ func (f *Phlare) initServer() (services.Service, error) { f.reg.MustRegister(collectors.NewGoCollector( collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll), )) - prometheus.MustRegister() DisableSignalHandling(&f.Cfg.Server) f.Cfg.Server.Registerer = prometheus.WrapRegistererWithPrefix("phlare_", f.reg) // Not all default middleware works with http2 so we'll add then manually.