mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-02-08 05:56:37 +00:00
process: Use registry collector for V1 data (#1814)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -27,19 +27,25 @@ import (
|
||||
"github.com/alecthomas/kingpin/v2"
|
||||
"github.com/prometheus-community/windows_exporter/internal/collector/update"
|
||||
"github.com/prometheus-community/windows_exporter/internal/mi"
|
||||
"github.com/prometheus-community/windows_exporter/internal/perfdata"
|
||||
"github.com/prometheus-community/windows_exporter/internal/pdh"
|
||||
"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]) {
|
||||
func FuncBenchmarkCollector[C collector.Collector](b *testing.B, name string, collectFunc collector.BuilderWithFlags[C], fn ...func(app *kingpin.Application)) {
|
||||
b.Helper()
|
||||
|
||||
logger := slog.New(slog.NewTextHandler(io.Discard, nil))
|
||||
|
||||
c := collectFunc(kingpin.CommandLine)
|
||||
app := kingpin.New("windows_exporter", "Windows metrics exporter.")
|
||||
c := collectFunc(app)
|
||||
|
||||
for _, f := range fn {
|
||||
f(app)
|
||||
}
|
||||
|
||||
collectors := collector.New(map[string]collector.Collector{name: c})
|
||||
require.NoError(b, collectors.Build(logger))
|
||||
|
||||
@@ -96,8 +102,8 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
|
||||
switch {
|
||||
case err == nil:
|
||||
case errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE),
|
||||
errors.Is(err, perfdata.NewPdhError(perfdata.PdhCstatusNoCounter)),
|
||||
errors.Is(err, perfdata.NewPdhError(perfdata.PdhCstatusNoObject)),
|
||||
errors.Is(err, pdh.NewPdhError(pdh.CstatusNoCounter)),
|
||||
errors.Is(err, pdh.NewPdhError(pdh.CstatusNoObject)),
|
||||
errors.Is(err, update.ErrUpdateServiceDisabled),
|
||||
errors.Is(err, os.ErrNotExist):
|
||||
default:
|
||||
@@ -111,8 +117,8 @@ func TestCollector[C collector.Collector, V interface{}](t *testing.T, fn func(*
|
||||
switch {
|
||||
// container collector
|
||||
case errors.Is(err, windows.Errno(2151088411)),
|
||||
errors.Is(err, perfdata.ErrPerformanceCounterNotInitialized),
|
||||
errors.Is(err, perfdata.ErrNoData),
|
||||
errors.Is(err, pdh.ErrPerformanceCounterNotInitialized),
|
||||
errors.Is(err, pdh.ErrNoData),
|
||||
errors.Is(err, mi.MI_RESULT_INVALID_NAMESPACE),
|
||||
errors.Is(err, mi.MI_RESULT_INVALID_QUERY),
|
||||
errors.Is(err, update.ErrNoUpdates):
|
||||
|
||||
Reference in New Issue
Block a user