collector: publish base units and _total counter names (#2743)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-16 10:48:26 +02:00
committed by GitHub
parent dc8092f46d
commit 3fb18521f6
131 changed files with 1674 additions and 1459 deletions
@@ -25,7 +25,6 @@ import (
"slices"
"strings"
"time"
"unsafe"
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/labelcache"
@@ -34,7 +33,6 @@ import (
"github.com/prometheus-community/windows_exporter/internal/scrapecache"
"github.com/prometheus-community/windows_exporter/internal/utils/recovery"
"github.com/prometheus/client_golang/prometheus"
"golang.org/x/sys/windows"
)
type perfCollector[T any] interface {
@@ -78,11 +76,10 @@ type Collector struct {
// labels keeps the label pairs of the series of the last scrape. The
// counters change on every scrape, but their process labels stay the
// same while the process runs.
labels labelcache.Cache
config Config
logger *slog.Logger
perfFrequency float64
closeFns []func()
labels labelcache.Cache
config Config
logger *slog.Logger
closeFns []func()
// perfQuery samples the counters of all enabled sub-collectors at once.
// The .NET CLR counter provider serves one query at a time and walks
// every .NET process for each, so separate queries wait for each other.
@@ -231,16 +228,6 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
}
c.logger = logger
if slices.Contains(c.config.CollectorsEnabled, collectorClrJIT) || slices.Contains(c.config.CollectorsEnabled, collectorClrSecurity) {
var frequency int64
ret, _, err := windows.NewLazySystemDLL("kernel32.dll").NewProc("QueryPerformanceFrequency").Call(uintptr(unsafe.Pointer(&frequency)))
if ret == 0 || frequency <= 0 {
return fmt.Errorf("QueryPerformanceFrequency: %w", err)
}
c.perfFrequency = float64(frequency)
}
var err error