diff options
author | Till <2353100+S7evinK@users.noreply.github.com> | 2022-04-08 12:24:40 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-08 12:24:40 +0200 |
commit | e8dd37d533275233b7bebeeb70b996e166cf2d3b (patch) | |
tree | 5316a53ae7dc2931b4e74e9cc64d9702cd9d4a79 /clientapi | |
parent | 25d99c44733036a638eb2e5061e42e90dd089f0e (diff) |
Add metrics for internal API requests (#2310)
* Add response size and requests total to internal handler
* Move MustRegister calls to New* funcs
* Move MustRegister back to init
* Init at some place, minimize changes
Diffstat (limited to 'clientapi')
-rw-r--r-- | clientapi/routing/register.go | 5 | ||||
-rw-r--r-- | clientapi/routing/routing.go | 3 | ||||
-rw-r--r-- | clientapi/routing/sendevent.go | 4 |
3 files changed, 3 insertions, 9 deletions
diff --git a/clientapi/routing/register.go b/clientapi/routing/register.go index 7d84f249..8253f315 100644 --- a/clientapi/routing/register.go +++ b/clientapi/routing/register.go @@ -64,11 +64,6 @@ const ( sessionIDLength = 24 ) -func init() { - // Register prometheus metrics. They must be registered to be exposed. - prometheus.MustRegister(amtRegUsers) -} - // sessionsDict keeps track of completed auth stages for each session. // It shouldn't be passed by value because it contains a mutex. type sessionsDict struct { diff --git a/clientapi/routing/routing.go b/clientapi/routing/routing.go index 32e83187..37d825b8 100644 --- a/clientapi/routing/routing.go +++ b/clientapi/routing/routing.go @@ -37,6 +37,7 @@ import ( "github.com/matrix-org/gomatrixserverlib" "github.com/matrix-org/util" "github.com/nats-io/nats.go" + "github.com/prometheus/client_golang/prometheus" "github.com/sirupsen/logrus" ) @@ -60,6 +61,8 @@ func Setup( extRoomsProvider api.ExtraPublicRoomsProvider, mscCfg *config.MSCs, natsClient *nats.Conn, ) { + prometheus.MustRegister(amtRegUsers, sendEventDuration) + rateLimits := httputil.NewRateLimits(&cfg.RateLimiting) userInteractiveAuth := auth.NewUserInteractive(userAPI, cfg) diff --git a/clientapi/routing/sendevent.go b/clientapi/routing/sendevent.go index c5884e80..1211fa72 100644 --- a/clientapi/routing/sendevent.go +++ b/clientapi/routing/sendevent.go @@ -46,10 +46,6 @@ var ( userRoomSendMutexes sync.Map // (roomID+userID) -> mutex. mutexes to ensure correct ordering of sendEvents ) -func init() { - prometheus.MustRegister(sendEventDuration) -} - var sendEventDuration = prometheus.NewHistogramVec( prometheus.HistogramOpts{ Namespace: "dendrite", |