@@ -7,7 +7,6 @@ package stats
77
88import (
99 "net/http"
10- "regexp"
1110 "strings"
1211 ratomic "sync/atomic"
1312 "time"
@@ -17,7 +16,6 @@ import (
1716 "github.com/NVIDIA/aistore/memsys"
1817
1918 "github.com/prometheus/client_golang/prometheus"
20- "github.com/prometheus/client_golang/prometheus/collectors"
2119 "github.com/prometheus/client_golang/prometheus/promhttp"
2220)
2321
@@ -47,38 +45,14 @@ var (
4745 staticLabs = prometheus.Labels {ConstlabNode : "" }
4846)
4947
48+ // 1) initialize Prometheus registry without default Go/process collectors
49+ // 2) register Go runtime collector - a no-op unless feat.EnableGoRuntimeMetrics
5050func initProm (snode * meta.Snode ) {
5151 promRegistry = prometheus .NewRegistry ()
5252
5353 staticLabs [ConstlabNode ] = strings .ReplaceAll (snode .ID (), "." , "_" )
54- }
5554
56- // Expose a low-cardinality subset of Go runtime metrics on the AIS Prometheus registry:
57- // - base collector (unconditional):
58- // go_goroutines, go_threads, go_info, go_gc_duration_seconds, go_memstats_last_gc_time_seconds
59- // - default runtime/metrics matcher:
60- // go_gc_gogc_percent, go_gc_gomemlimit_bytes, go_sched_gomaxprocs_threads
61- // - explicit picks via WithGoCollectorRuntimeMetrics below (one series each)
62- func regGoRuntime (daeType string ) {
63- nodeLabs := prometheus.Labels {
64- ConstlabNode : staticLabs [ConstlabNode ],
65- ConstlabComponent : daeType ,
66- }
67- reg := prometheus .WrapRegistererWith (nodeLabs , promRegistry )
68- reg .MustRegister (collectors .NewGoCollector (
69- // skip legacy go_memstats_* block (21 series, mostly duplicative); use runtime/metrics names instead
70- collectors .WithGoCollectorMemStatsMetricsDisabled (),
71- collectors .WithGoCollectorRuntimeMetrics (
72- collectors.GoRuntimeMetricsRule {Matcher : regexp .MustCompile (
73- `^/memory/classes/heap/objects:bytes$` + // heap in use
74- `|^/memory/classes/total:bytes$` + // total from OS
75- `|^/gc/heap/goal:bytes$` + // next GC target
76- `|^/gc/heap/allocs:bytes$` + // cumulative alloc bytes (counter)
77- `|^/cpu/classes/gc/total:cpu-seconds$` + // cumulative GC CPU time
78- `|^/gc/cycles/total:gc-cycles$` , // cumulative GC cycle count
79- )},
80- ),
81- ))
55+ regGoRuntime (snode .Type ())
8256}
8357
8458// usage: log resulting `copyValue` numbers:
0 commit comments