mirror of
https://github.com/prometheus-community/windows_exporter.git
synced 2026-10-30 15:39:04 +01:00
memory: publish pool allocation counts as gauges (#2721)
Signed-off-by: Jan-Otto Kröpke <mail@jkroepke.de>
This commit is contained in:
@@ -64,9 +64,9 @@ type Collector struct {
|
||||
swapPagesWrittenTotal *prometheus.Desc
|
||||
swapPageOperationsTotal *prometheus.Desc
|
||||
swapPageWritesTotal *prometheus.Desc
|
||||
poolNonPagedAllocationsTotal *prometheus.Desc
|
||||
poolNonPagedAllocations *prometheus.Desc
|
||||
poolNonPagedBytes *prometheus.Desc
|
||||
poolPagedAllocationsTotal *prometheus.Desc
|
||||
poolPagedAllocations *prometheus.Desc
|
||||
poolPagedBytes *prometheus.Desc
|
||||
poolPagedResidentBytes *prometheus.Desc
|
||||
standbyCacheCoreBytes *prometheus.Desc
|
||||
@@ -210,9 +210,9 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.poolNonPagedAllocationsTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "pool_nonpaged_allocs_total"),
|
||||
"The number of calls to allocate space in the nonpaged pool. The nonpaged pool is an area of system memory area for objects that cannot be written"+
|
||||
c.poolNonPagedAllocations = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "pool_nonpaged_allocs"),
|
||||
"Number of allocations in the nonpaged pool, regardless of their size. The nonpaged pool is an area of system memory for objects that cannot be written"+
|
||||
" to disk, and must remain in physical memory as long as they are allocated (PoolNonpagedAllocs)",
|
||||
nil,
|
||||
nil,
|
||||
@@ -224,9 +224,9 @@ func (c *Collector) Build(logger *slog.Logger, _ *mi.Session) error {
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
c.poolPagedAllocationsTotal = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "pool_paged_allocs_total"),
|
||||
"Number of calls to allocate space in the paged pool, regardless of the amount of space allocated in each call (PoolPagedAllocs)",
|
||||
c.poolPagedAllocations = prometheus.NewDesc(
|
||||
prometheus.BuildFQName(types.Namespace, Name, "pool_paged_allocs"),
|
||||
"Number of allocations in the paged pool, regardless of their size (PoolPagedAllocs)",
|
||||
nil,
|
||||
nil,
|
||||
)
|
||||
@@ -491,7 +491,7 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.poolNonPagedAllocationsTotal,
|
||||
c.poolNonPagedAllocations,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].PoolNonpagedAllocs,
|
||||
)
|
||||
@@ -503,8 +503,8 @@ func (c *Collector) collectPDH(ch chan<- prometheus.Metric) error {
|
||||
)
|
||||
|
||||
ch <- prometheus.MustNewConstMetric(
|
||||
c.poolPagedAllocationsTotal,
|
||||
prometheus.CounterValue,
|
||||
c.poolPagedAllocations,
|
||||
prometheus.GaugeValue,
|
||||
c.perfDataObject[0].PoolPagedAllocs,
|
||||
)
|
||||
|
||||
|
||||
@@ -22,6 +22,8 @@ import (
|
||||
|
||||
"github.com/prometheus-community/windows_exporter/internal/collector/memory"
|
||||
"github.com/prometheus-community/windows_exporter/internal/utils/testutils"
|
||||
dto "github.com/prometheus/client_model/go"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func BenchmarkCollector(b *testing.B) {
|
||||
@@ -29,5 +31,13 @@ func BenchmarkCollector(b *testing.B) {
|
||||
}
|
||||
|
||||
func TestCollector(t *testing.T) {
|
||||
testutils.TestCollector(t, memory.New, nil)
|
||||
families := testutils.TestCollector(t, memory.New, nil)
|
||||
|
||||
// "Pool Paged Allocs" and "Pool Nonpaged Allocs" are PERF_COUNTER_RAWCOUNT,
|
||||
// an instantaneous value.
|
||||
for _, name := range []string{"windows_memory_pool_paged_allocs", "windows_memory_pool_nonpaged_allocs"} {
|
||||
require.Contains(t, families, name)
|
||||
require.Equal(t, dto.MetricType_GAUGE, families[name].GetType(), name)
|
||||
require.NotContains(t, families, name+"_total")
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user