Skip to content

Commit

Permalink
libvuln: add pgxpool metrics
Browse files Browse the repository at this point in the history
Signed-off-by: Iain Duncan <iain.duncan@uk.ibm.com>
  • Loading branch information
iainduncani authored and hdonnay committed Feb 7, 2022
1 parent df1115a commit 2f312f0
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions libvuln/opts.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ import (
"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v4/pgxpool"
"github.com/jackc/pgx/v4/stdlib"
"github.com/prometheus/client_golang/prometheus"
"github.com/quay/zlog"
"github.com/remind101/migrate"
"go.opentelemetry.io/otel/baggage"
"go.opentelemetry.io/otel/label"

"github.com/quay/claircore/libvuln/driver"
"github.com/quay/claircore/libvuln/migrations"
"github.com/quay/claircore/pkg/poolstats"
)

const (
Expand Down Expand Up @@ -178,6 +180,11 @@ func (o *Opts) pool(ctx context.Context) (*pgxpool.Pool, error) {
if err != nil {
return nil, fmt.Errorf("failed to create Pool: %v", err)
}

if err := prometheus.Register(poolstats.NewCollector(pool, "libvuln")); err != nil {
zlog.Info(ctx).Msg("pool metrics already registered")
}

return pool, nil
}

Expand Down

0 comments on commit 2f312f0

Please sign in to comment.