FIX: [grid2] avoid initializing metrics twice

This commit is contained in:
gx578007 2023-03-06 16:56:40 +08:00
parent 1dd6f9ef3e
commit d4912ed3cd

View File

@ -1,6 +1,8 @@
package grid2
import "github.com/prometheus/client_golang/prometheus"
import (
"github.com/prometheus/client_golang/prometheus"
)
var (
metricsGridNum *prometheus.GaugeVec
@ -32,6 +34,10 @@ func mergeLabels(a, b prometheus.Labels) prometheus.Labels {
}
func initMetrics(extendedLabels []string) {
if metricsGridNum != nil {
return
}
metricsGridNum = prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Name: "bbgo_grid2_num",
@ -110,4 +116,4 @@ func registerMetrics() {
metricsGridOrderPrices,
)
metricsRegistered = true
}
}