Move MustRegister back to init

This commit is contained in:
Till Faelligen 2022-03-28 11:13:32 +02:00
parent 1afd2c07a8
commit 1c3606e4aa
2 changed files with 13 additions and 7 deletions

View file

@ -73,6 +73,13 @@ var destinationQueueBackingOff = prometheus.NewGauge(
},
)
func init() {
prometheus.MustRegister(
destinationQueueTotal, destinationQueueRunning,
destinationQueueBackingOff,
)
}
// NewOutgoingQueues makes a new OutgoingQueues
func NewOutgoingQueues(
db storage.Database,
@ -84,10 +91,6 @@ func NewOutgoingQueues(
statistics *statistics.Statistics,
signing *SigningInfo,
) *OutgoingQueues {
prometheus.MustRegister(
destinationQueueTotal, destinationQueueRunning,
destinationQueueBackingOff,
)
queues := &OutgoingQueues{
disabled: disabled,
process: process,

View file

@ -42,6 +42,12 @@ var (
)
)
func init() {
prometheus.MustRegister(
deviceListUpdateCount,
)
}
// DeviceListUpdater handles device list updates from remote servers.
//
// In the case where we have the prev_id for an update, the updater just stores the update (after acquiring a per-user lock).
@ -123,9 +129,6 @@ func NewDeviceListUpdater(
db DeviceListUpdaterDatabase, api DeviceListUpdaterAPI, producer KeyChangeProducer,
fedClient fedsenderapi.FederationClient, numWorkers int,
) *DeviceListUpdater {
prometheus.MustRegister(
deviceListUpdateCount,
)
return &DeviceListUpdater{
userIDToMutex: make(map[string]*sync.Mutex),
mu: &sync.Mutex{},