From 1c3606e4aa0d3bea070000ab35f36286d97bc71a Mon Sep 17 00:00:00 2001 From: Till Faelligen Date: Mon, 28 Mar 2022 11:13:32 +0200 Subject: [PATCH] Move MustRegister back to init --- federationapi/queue/queue.go | 11 +++++++---- keyserver/internal/device_list_update.go | 9 ++++++--- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/federationapi/queue/queue.go b/federationapi/queue/queue.go index 1869e4369..1e342b6a9 100644 --- a/federationapi/queue/queue.go +++ b/federationapi/queue/queue.go @@ -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, diff --git a/keyserver/internal/device_list_update.go b/keyserver/internal/device_list_update.go index 9f66e2b9c..4b2b8c187 100644 --- a/keyserver/internal/device_list_update.go +++ b/keyserver/internal/device_list_update.go @@ -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{},