diff --git a/internal/perfdata/collector.go b/internal/perfdata/collector.go index 1267ba0471..c949b0e92c 100644 --- a/internal/perfdata/collector.go +++ b/internal/perfdata/collector.go @@ -315,9 +315,11 @@ func (c *Collector) Close() { if c.collectCh != nil { close(c.collectCh) } + if c.counterValuesCh != nil { close(c.counterValuesCh) } + if c.errorCh != nil { close(c.errorCh) } diff --git a/internal/utils/testutils/testutils.go b/internal/utils/testutils/testutils.go index bd87ccd153..89ef9bf44a 100644 --- a/internal/utils/testutils/testutils.go +++ b/internal/utils/testutils/testutils.go @@ -21,7 +21,6 @@ import ( "log/slog" "os" "sync" - "syscall" "testing" "time" @@ -32,6 +31,7 @@ import ( "github.com/prometheus-community/windows_exporter/pkg/collector" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" + "golang.org/x/sys/windows" ) func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, collectFunc collector.BuilderWithFlags[C]) { @@ -92,6 +92,7 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(* }() err = c.Build(logger, miSession) + switch { case err == nil: case errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE), @@ -108,7 +109,7 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(* switch { // container collector - case errors.Is(err, syscall.Errno(2151088411)), + case errors.Is(err, windows.Errno(2151088411)), errors.Is(err, perfdata.ErrPerformanceCounterNotInitialized), errors.Is(err, perfdata.ErrNoData), errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE),