From 0a338ea94b9c9ecb778348ab9ca62442dd9e76b9 Mon Sep 17 00:00:00 2001 From: Roman Khimov Date: Mon, 21 Mar 2022 23:18:00 +0300 Subject: [PATCH] rpc/server: register ws calls in Prometheus They were completely missing. --- pkg/rpc/server/prometheus.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/pkg/rpc/server/prometheus.go b/pkg/rpc/server/prometheus.go index ccc4d4cc6..60b1351bf 100644 --- a/pkg/rpc/server/prometheus.go +++ b/pkg/rpc/server/prometheus.go @@ -16,16 +16,23 @@ func incCounter(name string) { } } +func regCounter(call string) { + ctr := prometheus.NewCounter( + prometheus.CounterOpts{ + Help: fmt.Sprintf("Number of calls to %s rpc endpoint", call), + Name: fmt.Sprintf("%s_called", call), + Namespace: "neogo", + }, + ) + prometheus.MustRegister(ctr) + rpcCounter[call] = ctr +} + func init() { for call := range rpcHandlers { - ctr := prometheus.NewCounter( - prometheus.CounterOpts{ - Help: fmt.Sprintf("Number of calls to %s rpc endpoint", call), - Name: fmt.Sprintf("%s_called", call), - Namespace: "neogo", - }, - ) - prometheus.MustRegister(ctr) - rpcCounter[call] = ctr + regCounter(call) + } + for call := range rpcWsHandlers { + regCounter(call) } }