mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-28 23:56:36 +00:00
Service Api collection close servicehandler to avoid memory leak
Signed-off-by: Alvaro Cabanas <acabanas@newrelic.com>
This commit is contained in:
@@ -246,18 +246,17 @@ func (c *serviceCollector) collectAPI(ch chan<- prometheus.Metric) error {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
defer serviceHandle.Close()
|
||||||
|
|
||||||
// Get Service Configuration
|
// Get Service Configuration
|
||||||
serviceConfig, err := serviceHandle.Config()
|
serviceConfig, err := serviceHandle.Config()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = serviceHandle.Close()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Service Current Status
|
// Get Service Current Status
|
||||||
serviceStatus, err := serviceHandle.Query()
|
serviceStatus, err := serviceHandle.Query()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
_ = serviceHandle.Close()
|
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user