From afc43a00680ddeb0d68326eed4a2cde2aed596f8 Mon Sep 17 00:00:00 2001 From: Daniel Krol Date: Wed, 21 Sep 2022 16:23:31 -0400 Subject: [PATCH] better prometheus tags --- metrics/metrics.go | 4 ++-- server/password.go | 2 +- server/wallet.go | 6 +++--- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/metrics/metrics.go b/metrics/metrics.go index db217e4..ec80263 100644 --- a/metrics/metrics.go +++ b/metrics/metrics.go @@ -13,14 +13,14 @@ var ( // Prometheus? Help: "Total number of requests to various endpoints", }, - []string{"method"}, + []string{"method", "endpoint"}, ) ErrorsCount = prometheus.NewCounterVec( prometheus.CounterOpts{ Name: "wallet_sync_error_count", Help: "Total number of various kinds of errors", }, - []string{"details"}, + []string{"error_type"}, ) ) diff --git a/server/password.go b/server/password.go index bff8801..0264daa 100644 --- a/server/password.go +++ b/server/password.go @@ -144,7 +144,7 @@ func (s *Server) changePassword(w http.ResponseWriter, req *http.Request) { select { case s.userRemove <- wsClientForUser{userId, nil}: case <-timeout.C: - metrics.ErrorsCount.With(prometheus.Labels{"details": "websocket user remove chan buffer full"}).Inc() + metrics.ErrorsCount.With(prometheus.Labels{"error_type": "ws-user-remove"}).Inc() return } timeout.Stop() diff --git a/server/wallet.go b/server/wallet.go index 267741f..76add5d 100644 --- a/server/wallet.go +++ b/server/wallet.go @@ -55,7 +55,7 @@ func (s *Server) handleWallet(w http.ResponseWriter, req *http.Request) { } func (s *Server) getWallet(w http.ResponseWriter, req *http.Request) { - metrics.RequestsCount.With(prometheus.Labels{"method": "GET wallet"}).Inc() + metrics.RequestsCount.With(prometheus.Labels{"method": "GET", "endpoint": "wallet"}).Inc() if !getGetData(w, req) { return @@ -109,7 +109,7 @@ func (s *Server) getWallet(w http.ResponseWriter, req *http.Request) { // current wallet's sequence // 500: Update unsuccessful for unanticipated reasons func (s *Server) postWallet(w http.ResponseWriter, req *http.Request) { - metrics.RequestsCount.With(prometheus.Labels{"method": "POST wallet"}).Inc() + metrics.RequestsCount.With(prometheus.Labels{"method": "POST", "endpoint": "wallet"}).Inc() var walletRequest WalletRequest if !getPostData(w, req, &walletRequest) { @@ -155,7 +155,7 @@ func (s *Server) postWallet(w http.ResponseWriter, req *http.Request) { select { case s.walletUpdates <- walletUpdateMsg{authToken.UserId, walletRequest.Sequence}: case <-timeout.C: - metrics.ErrorsCount.With(prometheus.Labels{"details": "client notify chan buffer full"}).Inc() + metrics.ErrorsCount.With(prometheus.Labels{"error_type": "ws-client-notify"}).Inc() } timeout.Stop() }