mirror of
https://github.com/prometheus-community/postgres_exporter
synced 2025-05-02 07:58:12 +00:00
probe: clean-up database connection after probe to prevent connection leak
Signed-off-by: Kurtis Bass <kurtis.bass@hinge.co>
This commit is contained in:
parent
9bd9d83d73
commit
76223cdda8
@ -104,6 +104,9 @@ func handleProbe(logger log.Logger) http.HandlerFunc {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Cleanup underlying connections to prevent connection leaks
|
||||||
|
defer pc.Close()
|
||||||
|
|
||||||
// TODO(@sysadmind): Remove the registry.MustRegister() call below and instead handle the collection here. That will allow
|
// TODO(@sysadmind): Remove the registry.MustRegister() call below and instead handle the collection here. That will allow
|
||||||
// for the passing of context, handling of timeouts, and more control over the collection.
|
// for the passing of context, handling of timeouts, and more control over the collection.
|
||||||
// The current NewProbeCollector() implementation relies on the MustNewConstMetric() call to create the metrics which is not
|
// The current NewProbeCollector() implementation relies on the MustNewConstMetric() call to create the metrics which is not
|
||||||
|
@ -83,3 +83,7 @@ func (pc *ProbeCollector) Collect(ch chan<- prometheus.Metric) {
|
|||||||
}
|
}
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (pc *ProbeCollector) Close() error {
|
||||||
|
return pc.db.Close()
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user