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 // NewOutgoingQueues makes a new OutgoingQueues
func NewOutgoingQueues( func NewOutgoingQueues(
db storage.Database, db storage.Database,
@ -84,10 +91,6 @@ func NewOutgoingQueues(
statistics *statistics.Statistics, statistics *statistics.Statistics,
signing *SigningInfo, signing *SigningInfo,
) *OutgoingQueues { ) *OutgoingQueues {
prometheus.MustRegister(
destinationQueueTotal, destinationQueueRunning,
destinationQueueBackingOff,
)
queues := &OutgoingQueues{ queues := &OutgoingQueues{
disabled: disabled, disabled: disabled,
process: process, process: process,

View file

@ -42,6 +42,12 @@ var (
) )
) )
func init() {
prometheus.MustRegister(
deviceListUpdateCount,
)
}
// DeviceListUpdater handles device list updates from remote servers. // 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). // 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, db DeviceListUpdaterDatabase, api DeviceListUpdaterAPI, producer KeyChangeProducer,
fedClient fedsenderapi.FederationClient, numWorkers int, fedClient fedsenderapi.FederationClient, numWorkers int,
) *DeviceListUpdater { ) *DeviceListUpdater {
prometheus.MustRegister(
deviceListUpdateCount,
)
return &DeviceListUpdater{ return &DeviceListUpdater{
userIDToMutex: make(map[string]*sync.Mutex), userIDToMutex: make(map[string]*sync.Mutex),
mu: &sync.Mutex{}, mu: &sync.Mutex{},