Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
huangqing.zhu committed Nov 5, 2024
1 parent 687346e commit 943370b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 6 deletions.
5 changes: 2 additions & 3 deletions collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func (c *client) RegisterCollector(rc RegisterCollectorFunc) {
})
}

var colOnceMap sync.Map
var colOnce sync.Once
var col = &collector{
delayLengthDesc: prometheus.NewDesc(
prometheus.BuildFQName(namespace, "delay", "queue_length"),
Expand All @@ -40,8 +40,7 @@ type collector struct {

func registerCollector(rc RegisterCollectorFunc, c *client) {
col.cs.Store(c, struct{}{})
m, _ := colOnceMap.LoadOrStore(rc, &sync.Once{})
m.(*sync.Once).Do(func() {
colOnce.Do(func() {
rc(col)
})
}
Expand Down
5 changes: 2 additions & 3 deletions metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ const (
)

var (
metricOnceMap sync.Map
metricOnce sync.Once
metric *prometheus.SummaryVec
errMetric, hitsMetric, missMetric *prometheus.CounterVec
delayPollErrorMetric, delayReclaimErrorMetric, delayReclaimCountMetric *prometheus.CounterVec
Expand Down Expand Up @@ -55,8 +55,7 @@ func init() {
}

func registerMetric(rc RegisterCollectorFunc) {
m, _ := metricOnceMap.LoadOrStore(rc, &sync.Once{})
m.(*sync.Once).Do(func() {
metricOnce.Do(func() {
rc(errMetric)
rc(hitsMetric)
rc(missMetric)
Expand Down

0 comments on commit 943370b

Please sign in to comment.