Update likwidMetric.go

Fixes a potential bug when `fsnotify.NewWatcher()` fails with an error
This commit is contained in:
Thomas Gruber
2023-08-18 11:27:47 +02:00
committed by GitHub
parent e425b2c38e
commit fc19b2b9a5

@@ -344,6 +344,7 @@ func (m *LikwidCollector) takeMeasurement(evidx int, evset LikwidEventsetConfig,
watcher, err := fsnotify.NewWatcher() watcher, err := fsnotify.NewWatcher()
if err != nil { if err != nil {
cclog.ComponentError(m.name, err.Error()) cclog.ComponentError(m.name, err.Error())
return true, err
} }
defer watcher.Close() defer watcher.Close()
if len(m.config.LockfilePath) > 0 { if len(m.config.LockfilePath) > 0 {