1- package pgx_prometheus
1+ package pgxpool_prometheus
22
33import (
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