Skip to content

Commit 500b8f2

Browse files
dehaansacristiangreco
authored andcommitted
Port fix for pg17 to grafana fork
1 parent 83cecbf commit 500b8f2

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

collector/pg_stat_bgwriter.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,9 @@ var (
125125
)
126126

127127
func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, ch chan<- prometheus.Metric) error {
128+
db := instance.getDB()
129+
128130
if instance.version.GE(semver.MustParse("17.0.0")) {
129-
db := instance.getDB()
130131
row := db.QueryRowContext(ctx, statBGWriterQueryAfter17)
131132

132133
var bc, mwc, ba sql.NullInt64
@@ -174,8 +175,8 @@ func (PGStatBGWriterCollector) Update(ctx context.Context, instance *instance, c
174175
srMetric,
175176
)
176177
} else {
177-
db := instance.getDB()
178-
row := db.QueryRowContext(ctx, statBGWriterQueryBefore17)
178+
row := db.QueryRowContext(ctx,
179+
statBGWriterQueryBefore17)
179180

180181
var cpt, cpr, bcp, bc, mwc, bb, bbf, ba sql.NullInt64
181182
var cpwt, cpst sql.NullFloat64

0 commit comments

Comments
 (0)