Skip to content

Commit

Permalink
feat: add perfcounter.engine CLI option as alternative to WINDOWS_EXP…
Browse files Browse the repository at this point in the history
…ORTER_PERF_COUNTERS_ENGINE env

Signed-off-by: Jan-Otto Kröpke <[email protected]>
  • Loading branch information
jkroepke committed Nov 9, 2024
1 parent 969b90e commit 50d64e1
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 3 deletions.
4 changes: 2 additions & 2 deletions exporter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down Expand Up @@ -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()
)

Expand Down
1 change: 1 addition & 0 deletions internal/collector/cpu/cpu.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
)

Expand Down
4 changes: 3 additions & 1 deletion internal/testutils/testutils.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 50d64e1

Please sign in to comment.