Skip to content

Commit

Permalink
Enable go and process metrics collectors (#309)
Browse files Browse the repository at this point in the history
  • Loading branch information
snormore authored Sep 28, 2023
1 parent 663eea3 commit c025a6f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/e2e/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"time"

"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"go.uber.org/zap"
"golang.org/x/sync/errgroup"

Expand All @@ -21,11 +22,14 @@ type Runner struct {
}

func NewRunner(ctx context.Context, log *zap.Logger, config *Config) *Runner {
promReg := prometheus.NewRegistry()
promReg.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
promReg.MustRegister(collectors.NewGoCollector())
return &Runner{
ctx: ctx,
log: log,
config: config,
prom: prometheus.NewRegistry(),
prom: promReg,
suite: NewSuite(ctx, log, config),
}
}
Expand Down
3 changes: 3 additions & 0 deletions pkg/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"github.com/multiformats/go-multiaddr"
"github.com/pkg/errors"
"github.com/prometheus/client_golang/prometheus"
"github.com/prometheus/client_golang/prometheus/collectors"
"github.com/uptrace/bun"
"github.com/uptrace/bun/dialect/pgdialect"
"github.com/uptrace/bun/driver/pgdriver"
Expand Down Expand Up @@ -87,6 +88,8 @@ func New(ctx context.Context, log *zap.Logger, options Options) (*Server, error)
s.ctx, s.cancel = context.WithCancel(ctx)

promReg := prometheus.NewRegistry()
promReg.MustRegister(collectors.NewProcessCollector(collectors.ProcessCollectorOpts{}))
promReg.MustRegister(collectors.NewGoCollector())
if options.Metrics.Enable {
s.metricsServer, err = metrics.NewMetricsServer(s.ctx, options.Metrics.Address, options.Metrics.Port, s.log, promReg)
if err != nil {
Expand Down

0 comments on commit c025a6f

Please sign in to comment.