Skip to content

Commit 94a89b0

Browse files
authored
Merge pull request #734 from kjbass/master
Close DB connection after probe completes.
2 parents 7259eec + 76223cd commit 94a89b0

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

cmd/postgres_exporter/probe.go

+3
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,9 @@ func handleProbe(logger log.Logger) http.HandlerFunc {
104104
return
105105
}
106106

107+
// Cleanup underlying connections to prevent connection leaks
108+
defer pc.Close()
109+
107110
// TODO(@sysadmind): Remove the registry.MustRegister() call below and instead handle the collection here. That will allow
108111
// for the passing of context, handling of timeouts, and more control over the collection.
109112
// The current NewProbeCollector() implementation relies on the MustNewConstMetric() call to create the metrics which is not

collector/probe.go

+4
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,7 @@ func (pc *ProbeCollector) Collect(ch chan<- prometheus.Metric) {
8383
}
8484
wg.Wait()
8585
}
86+
87+
func (pc *ProbeCollector) Close() error {
88+
return pc.db.Close()
89+
}

0 commit comments

Comments
 (0)