Skip to content

Commit

Permalink
replace custom pgxpool collector with opensource module
Browse files Browse the repository at this point in the history
  • Loading branch information
vroldanbet committed Sep 14, 2022
1 parent 6015d03 commit ffdf521
Show file tree
Hide file tree
Showing 6 changed files with 8 additions and 224 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ go 1.19

require (
cloud.google.com/go/spanner v1.37.0
github.com/IBM/pgxpoolprometheus v1.0.1
github.com/Masterminds/squirrel v1.5.3
github.com/authzed/authzed-go v0.6.1-0.20220907110811-dcd2429c6178
github.com/authzed/grpcutil v0.0.0-20220104222419-f813f77722e5
Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,8 @@ github.com/Azure/go-autorest/logger v0.2.1/go.mod h1:T9E3cAhj2VqvPOtCYAvby9aBXkZ
github.com/Azure/go-autorest/tracing v0.6.0/go.mod h1:+vhtPC754Xsa23ID7GlGsrdKBpUA79WCAKPPZVC2DeU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/IBM/pgxpoolprometheus v1.0.1 h1:hE1Dd2XgNw/OiLzNhGVAxES7HJRxive+3nBfIiiUq+w=
github.com/IBM/pgxpoolprometheus v1.0.1/go.mod h1:IfdL29gucelTxg1M11i7ZjHLizUlZ0UfOI0yfC1r6Wk=
github.com/Masterminds/semver/v3 v3.1.1 h1:hLg3sBzpNErnxhQtUy/mmLR2I9foDujNK030IGemrRc=
github.com/Masterminds/semver/v3 v3.1.1/go.mod h1:VPu/7SZ7ePZ3QOrcuXROw5FAcLl4a0cBrbBpGY/8hQs=
github.com/Masterminds/squirrel v1.5.3 h1:YPpoceAcxuzIljlr5iWpNKaql7hLeG1KLSrhvdHpkZc=
Expand Down
3 changes: 2 additions & 1 deletion internal/datastore/crdb/crdb.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"strconv"
"time"

"github.com/IBM/pgxpoolprometheus"
sq "github.com/Masterminds/squirrel"
"github.com/jackc/pgx/v4"
"github.com/jackc/pgx/v4/pgxpool"
Expand Down Expand Up @@ -82,7 +83,7 @@ func NewCRDBDatastore(url string, options ...Option) (datastore.Datastore, error
}

if config.enablePrometheusStats {
collector := pgxcommon.NewPgxpoolStatsCollector(pool, "spicedb")
collector := pgxpoolprometheus.NewCollector(pool, map[string]string{"db_name": "spicedb"})
if err := prometheus.Register(collector); err != nil {
return nil, fmt.Errorf(errUnableToInstantiate, err)
}
Expand Down
106 changes: 0 additions & 106 deletions internal/datastore/postgres/common/pgxpool_collector.go

This file was deleted.

114 changes: 0 additions & 114 deletions internal/datastore/postgres/common/pgxpool_collector_test.go

This file was deleted.

6 changes: 3 additions & 3 deletions internal/datastore/postgres/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import (
"fmt"
"time"

"golang.org/x/sync/errgroup"

"github.com/IBM/pgxpoolprometheus"
sq "github.com/Masterminds/squirrel"
"github.com/jackc/pgconn"
"github.com/jackc/pgx/v4"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/prometheus/client_golang/prometheus"
"github.com/rs/zerolog/log"
"go.opentelemetry.io/otel"
"golang.org/x/sync/errgroup"

"github.com/authzed/spicedb/internal/datastore/common"
"github.com/authzed/spicedb/internal/datastore/common/revisions"
Expand Down Expand Up @@ -110,7 +110,7 @@ func NewPostgresDatastore(
}

if config.enablePrometheusStats {
collector := pgxcommon.NewPgxpoolStatsCollector(dbpool, "spicedb")
collector := pgxpoolprometheus.NewCollector(dbpool, map[string]string{"db_name": "spicedb"})
if err := prometheus.Register(collector); err != nil {
return nil, fmt.Errorf(errUnableToInstantiate, err)
}
Expand Down

0 comments on commit ffdf521

Please sign in to comment.