Skip to content

Commit b67b435

Browse files
committed
metricsDescMap cleanup added
Signed-off-by: SHALINI JHA <[email protected]>
1 parent 25e5320 commit b67b435

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

collector/system_stats_collector.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ const prefix_stats = "spectrum_systemstats_"
2626

2727
var (
2828
metricsPromDescMap map[string]*prometheus.Desc
29-
metricsDescMap map[string]string
29+
metricsDescMap map[string]string //update InitmetricsDescMap function for any new stat added in lssystemstats api rsp
3030
)
3131

3232
type systemStatsCollector struct {
@@ -120,7 +120,7 @@ func NewSystemStatsCollector() (Collector, error) {
120120
for statName, statDef := range metricsDescMap {
121121
metricsPromDescMap[statName] = prometheus.NewDesc(prefix_stats+statName, statDef, labelnames, nil)
122122
}
123-
123+
metricsDescMap = nil //ready for cleanup
124124
return &systemStatsCollector{}, nil
125125
}
126126

@@ -178,6 +178,7 @@ func (c *systemStatsCollector) Collect(sClient utils.SpectrumClient, ch chan<- p
178178
for _, systemStat := range systemStats {
179179

180180
mrtricDesc, isExist := metricsPromDescMap[systemStat.Get("stat_name").String()]
181+
//new stat will be ignored if not added in metricsDescMap
181182
if isExist {
182183
ch <- prometheus.MustNewConstMetric(mrtricDesc, prometheus.GaugeValue, systemStat.Get("stat_current").Float(), labelvalues...)
183184
}

0 commit comments

Comments
 (0)