Skip to content

Commit

Permalink
Fix --const-label option (#113)
Browse files Browse the repository at this point in the history
Signed-off-by: tamareyal <[email protected]>
Co-authored-by: tamareyal <[email protected]>
  • Loading branch information
tamareyal and tamareyal authored Jan 14, 2025
1 parent 10abc54 commit 60d55fd
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion metrics/serve.go
Original file line number Diff line number Diff line change
Expand Up @@ -514,11 +514,12 @@ func (c *Collector) Run() error {
labelValues = append(labelValues, split[1])
}

mutableState := &metricState{seriesCount: c.cfg.SeriesCount}
mutableState := &metricState{seriesCount: c.cfg.SeriesCount, labelValues: labelValues}
// unsafe means you need to lock c.mu to use it.
unsafeReadOnlyGetState := func() metricState { return *mutableState }

c.mu.Lock() // Just to make race detector happy, not really needed in practice.
c.labelKeys = labelKeys
c.gauges = make([]*prometheus.GaugeVec, c.cfg.GaugeMetricCount)
c.counters = make([]*prometheus.CounterVec, c.cfg.CounterMetricCount)
c.histograms = make([]*prometheus.HistogramVec, c.cfg.HistogramMetricCount)
Expand Down

0 comments on commit 60d55fd

Please sign in to comment.