Skip to content

Commit 672c623

Browse files
committed
rename everything to use pgxpool instead of just pgx
1 parent ca0b3ae commit 672c623

File tree

3 files changed

+11
-11
lines changed

3 files changed

+11
-11
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func main() {
4242
panic(err)
4343
}
4444

45-
prometheus.MustRegister(pgxpool_prometheus.NewPgxStatsCollector(pool, "database"))
45+
prometheus.MustRegister(pgxpool_prometheus.NewPgxPoolStatsCollector(pool, "database"))
4646

4747
log.Fatalf("Error: %v", http.ListenAndServe(":8080", promhttp.Handler()))
4848
}

_example/example.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
"log"
66
"net/http"
77

8-
pgx_prometheus "github.com/cmackenzie1/pgxpool-prometheus"
8+
"github.com/cmackenzie1/pgxpool-prometheus"
99
"github.com/jackc/pgx/v5/pgxpool"
1010
"github.com/prometheus/client_golang/prometheus"
1111
"github.com/prometheus/client_golang/prometheus/promhttp"
@@ -25,7 +25,7 @@ func main() {
2525
}
2626
defer pool.Close()
2727

28-
prometheus.MustRegister(pgx_prometheus.NewPgxStatsCollector(pool, "database"))
28+
prometheus.MustRegister(pgxpool_prometheus.NewPgxPoolStatsCollector(pool, "database"))
2929

3030
if err := pool.QueryRow(context.Background(), "SELECT 1").Scan(nil); err != nil {
3131
panic(err)

collector.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
package pgx_prometheus
1+
package pgxpool_prometheus
22

33
import (
44
"github.com/jackc/pgx/v5/pgxpool"
55
"github.com/prometheus/client_golang/prometheus"
66
)
77

8-
// PgxPoolCollector is a Prometheus collector for pgx metrics.
8+
// PgxPoolStatsCollector is a Prometheus collector for pgx metrics.
99
// It implements the prometheus.Collector interface.
10-
type PgxPoolCollector struct {
10+
type PgxPoolStatsCollector struct {
1111
db *pgxpool.Pool
1212

1313
acquireConns *prometheus.Desc
@@ -22,16 +22,16 @@ type PgxPoolCollector struct {
2222
maxIdleDestroyCount *prometheus.Desc
2323
}
2424

25-
// NewPgxStatsCollector returns a new pgxCollector.
25+
// NewPgxPoolStatsCollector returns a new pgxCollector.
2626
// The dbName parameter is used to set the "db" label on the metrics.
2727
// The db parameter is the pgxpool.Pool to collect metrics from.
2828
// The db parameter must not be nil.
2929
// The dbName parameter must not be empty.
30-
func NewPgxStatsCollector(db *pgxpool.Pool, dbName string) *PgxPoolCollector {
30+
func NewPgxPoolStatsCollector(db *pgxpool.Pool, dbName string) *PgxPoolStatsCollector {
3131
fqName := func(name string) string {
3232
return prometheus.BuildFQName("pgx", "pool", name)
3333
}
34-
return &PgxPoolCollector{
34+
return &PgxPoolStatsCollector{
3535
db: db,
3636
acquireConns: prometheus.NewDesc(
3737
fqName("acquire_connections"),
@@ -97,7 +97,7 @@ func NewPgxStatsCollector(db *pgxpool.Pool, dbName string) *PgxPoolCollector {
9797
}
9898

9999
// Describe implements the prometheus.Collector interface.
100-
func (p PgxPoolCollector) Describe(descs chan<- *prometheus.Desc) {
100+
func (p PgxPoolStatsCollector) Describe(descs chan<- *prometheus.Desc) {
101101
descs <- p.acquireConns
102102
descs <- p.canceledAcquireCount
103103
descs <- p.constructingConns
@@ -111,7 +111,7 @@ func (p PgxPoolCollector) Describe(descs chan<- *prometheus.Desc) {
111111
}
112112

113113
// Collect implements the prometheus.Collector interface.
114-
func (p PgxPoolCollector) Collect(metrics chan<- prometheus.Metric) {
114+
func (p PgxPoolStatsCollector) Collect(metrics chan<- prometheus.Metric) {
115115
stats := p.db.Stat()
116116

117117
metrics <- prometheus.MustNewConstMetric(p.acquireConns, prometheus.GaugeValue, float64(stats.AcquiredConns()))

0 commit comments

Comments
 (0)