Skip to content

Commit 79f8b80

Browse files
Register all GO process metrics (#1010)
1 parent 309da68 commit 79f8b80

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

pkg/handler/handler.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ import (
1919
"path"
2020

2121
"github.com/frostbyte73/core"
22+
"github.com/prometheus/client_golang/prometheus"
23+
"github.com/prometheus/client_golang/prometheus/collectors"
2224
"google.golang.org/grpc"
2325

2426
"github.com/livekit/egress/pkg/config"
@@ -44,6 +46,10 @@ type Handler struct {
4446
}
4547

4648
func NewHandler(conf *config.PipelineConfig, bus psrpc.MessageBus) (*Handler, error) {
49+
// Register all GO process metrics
50+
prometheus.Unregister(prometheus.NewGoCollector())
51+
prometheus.MustRegister(collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll)))
52+
4753
ipcClient, err := ipc.NewServiceClient(path.Join(config.TmpDir, conf.NodeID))
4854
if err != nil {
4955
return nil, err

pkg/service/metrics.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121

2222
"github.com/linkdata/deadlock"
2323
"github.com/prometheus/client_golang/prometheus"
24+
"github.com/prometheus/client_golang/prometheus/collectors"
2425
"github.com/prometheus/client_golang/prometheus/promhttp"
2526
dto "github.com/prometheus/client_model/go"
2627
"github.com/prometheus/common/expfmt"
@@ -38,6 +39,9 @@ type MetricsService struct {
3839
}
3940

4041
func NewMetricsService(pm *ProcessManager) *MetricsService {
42+
prometheus.Unregister(prometheus.NewGoCollector())
43+
prometheus.MustRegister(collectors.NewGoCollector(collectors.WithGoCollectorRuntimeMetrics(collectors.MetricsAll)))
44+
4145
return &MetricsService{
4246
pm: pm,
4347
}

0 commit comments

Comments
 (0)