cache: emit copy-read hit totals as counters (#2602)

Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
Jan-Otto Kröpke
2026-10-09 11:19:09 +02:00
committed by GitHub
parent 1dddd629f4
commit 4072a20308
2 changed files with 104 additions and 3 deletions
+6 -3
View File
@@ -25,6 +25,7 @@ import (
"github.com/alecthomas/kingpin/v2"
"github.com/prometheus-community/windows_exporter/internal/mi"
"github.com/prometheus-community/windows_exporter/internal/pdh"
pdhtypes "github.com/prometheus-community/windows_exporter/internal/pdh/types"
"github.com/prometheus-community/windows_exporter/internal/types"
"github.com/prometheus/client_golang/prometheus"
)
@@ -40,7 +41,7 @@ var ConfigDefaults = Config{}
type Collector struct {
config Config
perfDataCollector *pdh.Collector[perfDataCounterValues]
perfDataCollector pdhtypes.Collector[perfDataCounterValues]
perfDataObject []perfDataCounterValues
asyncCopyReadsTotal *prometheus.Desc
@@ -95,7 +96,9 @@ func (c *Collector) GetName() string {
}
func (c *Collector) Close() error {
c.perfDataCollector.Close()
if c.perfDataCollector != nil {
c.perfDataCollector.Close()
}
return nil
}
@@ -327,7 +330,7 @@ func (c *Collector) Collect(ch chan<- prometheus.Metric, _ time.Duration) error
ch <- prometheus.MustNewConstMetric(
c.copyReadHitsTotal,
prometheus.GaugeValue,
prometheus.CounterValue,
c.perfDataObject[0].CopyReadHitsTotal,
)