Cleanup collectors (#826)
Fix up `replication` and `process_idle` Update input params to match the rest of the collectors. Signed-off-by: SuperQ <superq@gmail.com>
This commit is contained in:
parent
1a4e8993f6
commit
030a2a9bc7
|
@ -43,8 +43,8 @@ var pgProcessIdleSeconds = prometheus.NewDesc(
|
|||
prometheus.Labels{},
|
||||
)
|
||||
|
||||
func (PGProcessIdleCollector) Update(ctx context.Context, inst *instance, ch chan<- prometheus.Metric) error {
|
||||
db := inst.getDB()
|
||||
func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch chan<- prometheus.Metric) error {
|
||||
db := instance.getDB()
|
||||
row := db.QueryRowContext(ctx,
|
||||
`WITH
|
||||
metrics AS (
|
||||
|
|
|
@ -15,7 +15,6 @@ package collector
|
|||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
|
||||
"github.com/prometheus/client_golang/prometheus"
|
||||
)
|
||||
|
@ -64,7 +63,8 @@ var (
|
|||
END as is_replica`
|
||||
)
|
||||
|
||||
func (c *PGReplicationCollector) Update(ctx context.Context, db *sql.DB, ch chan<- prometheus.Metric) error {
|
||||
func (c *PGReplicationCollector) Update(ctx context.Context, instance *instance, ch chan<- prometheus.Metric) error {
|
||||
db := instance.getDB()
|
||||
row := db.QueryRowContext(ctx,
|
||||
pgReplicationQuery,
|
||||
)
|
||||
|
|
|
@ -29,6 +29,8 @@ func TestPgReplicationCollector(t *testing.T) {
|
|||
}
|
||||
defer db.Close()
|
||||
|
||||
inst := &instance{db: db}
|
||||
|
||||
columns := []string{"lag", "is_replica"}
|
||||
rows := sqlmock.NewRows(columns).
|
||||
AddRow(1000, 1)
|
||||
|
@ -39,7 +41,7 @@ func TestPgReplicationCollector(t *testing.T) {
|
|||
defer close(ch)
|
||||
c := PGReplicationCollector{}
|
||||
|
||||
if err := c.Update(context.Background(), db, ch); err != nil {
|
||||
if err := c.Update(context.Background(), inst, ch); err != nil {
|
||||
t.Errorf("Error calling PGReplicationCollector.Update: %s", err)
|
||||
}
|
||||
}()
|
||||
|
|
Loading…
Reference in New Issue