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{},
|
prometheus.Labels{},
|
||||||
)
|
)
|
||||||
|
|
||||||
func (PGProcessIdleCollector) Update(ctx context.Context, inst *instance, ch chan<- prometheus.Metric) error {
|
func (PGProcessIdleCollector) Update(ctx context.Context, instance *instance, ch chan<- prometheus.Metric) error {
|
||||||
db := inst.getDB()
|
db := instance.getDB()
|
||||||
row := db.QueryRowContext(ctx,
|
row := db.QueryRowContext(ctx,
|
||||||
`WITH
|
`WITH
|
||||||
metrics AS (
|
metrics AS (
|
||||||
|
|
|
@ -15,7 +15,6 @@ package collector
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"database/sql"
|
|
||||||
|
|
||||||
"github.com/prometheus/client_golang/prometheus"
|
"github.com/prometheus/client_golang/prometheus"
|
||||||
)
|
)
|
||||||
|
@ -64,7 +63,8 @@ var (
|
||||||
END as is_replica`
|
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,
|
row := db.QueryRowContext(ctx,
|
||||||
pgReplicationQuery,
|
pgReplicationQuery,
|
||||||
)
|
)
|
||||||
|
|
|
@ -29,6 +29,8 @@ func TestPgReplicationCollector(t *testing.T) {
|
||||||
}
|
}
|
||||||
defer db.Close()
|
defer db.Close()
|
||||||
|
|
||||||
|
inst := &instance{db: db}
|
||||||
|
|
||||||
columns := []string{"lag", "is_replica"}
|
columns := []string{"lag", "is_replica"}
|
||||||
rows := sqlmock.NewRows(columns).
|
rows := sqlmock.NewRows(columns).
|
||||||
AddRow(1000, 1)
|
AddRow(1000, 1)
|
||||||
|
@ -39,7 +41,7 @@ func TestPgReplicationCollector(t *testing.T) {
|
||||||
defer close(ch)
|
defer close(ch)
|
||||||
c := PGReplicationCollector{}
|
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)
|
t.Errorf("Error calling PGReplicationCollector.Update: %s", err)
|
||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
Loading…
Reference in New Issue