diff --git a/exporter.go b/exporter.go index 9067b6892..9dc55210e 100644 --- a/exporter.go +++ b/exporter.go @@ -8,7 +8,6 @@ package main //nolint:gofumpt import ( "github.com/prometheus-community/windows_exporter/internal/initiate" - "github.com/prometheus-community/windows_exporter/internal/toggle" "context" "errors" @@ -29,6 +28,7 @@ import ( "github.com/prometheus-community/windows_exporter/internal/httphandler" "github.com/prometheus-community/windows_exporter/internal/log" "github.com/prometheus-community/windows_exporter/internal/log/flag" + "github.com/prometheus-community/windows_exporter/internal/toggle" "github.com/prometheus-community/windows_exporter/internal/types" "github.com/prometheus-community/windows_exporter/internal/utils" "github.com/prometheus-community/windows_exporter/pkg/collector" @@ -100,7 +100,7 @@ func run() int { togglePDH = app.Flag( "perfcounter.engine", - "EXPERIMENTAL: Performance counter engine to use. Can be one of [\"pdh\", \"registy\"]. PDH is in experimental state. This flag will be removed in 0.31.", + "EXPERIMENTAL: Performance counter engine to use. Can be one of \"pdh\", \"registry\". PDH is in experimental state. This flag will be removed in 0.31.", ).Default("registry").String() ) diff --git a/internal/collector/cpu/cpu.go b/internal/collector/cpu/cpu.go index 35028c0ea..628d05dda 100644 --- a/internal/collector/cpu/cpu.go +++ b/internal/collector/cpu/cpu.go @@ -13,6 +13,7 @@ import ( v1 "github.com/prometheus-community/windows_exporter/internal/perfdata/v1" "github.com/prometheus-community/windows_exporter/internal/toggle" "github.com/prometheus-community/windows_exporter/internal/types" + "github.com/prometheus-community/windows_exporter/internal/utils" "github.com/prometheus/client_golang/prometheus" ) diff --git a/internal/testutils/testutils.go b/internal/testutils/testutils.go index 5be1c5081..83b38ca46 100644 --- a/internal/testutils/testutils.go +++ b/internal/testutils/testutils.go @@ -11,6 +11,7 @@ import ( "github.com/alecthomas/kingpin/v2" "github.com/prometheus-community/windows_exporter/internal/mi" + "github.com/prometheus-community/windows_exporter/internal/toggle" "github.com/prometheus-community/windows_exporter/pkg/collector" "github.com/prometheus/client_golang/prometheus" "github.com/stretchr/testify/require" @@ -46,7 +47,8 @@ func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, co func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*V) C, conf *V) { t.Helper() - t.Setenv("WINDOWS_EXPORTER_PERF_COUNTERS_ENGINE", "pdh") + + toggle.PHDEnabled = true var ( metrics []prometheus.Metric