Merge pull request #734 from kjbass/master

Close DB connection after probe completes.
This commit is contained in:
Joe Adams 2023-02-12 14:52:50 -05:00 committed by GitHub
commit 94a89b0166
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 0 deletions

View File

@ -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

View File

@ -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()
}