better prometheus tags

This commit is contained in:
Daniel Krol 2022-09-21 16:23:31 -04:00
parent a82a4e7290
commit afc43a0068
3 changed files with 6 additions and 6 deletions

View file

@ -13,14 +13,14 @@ var (
// Prometheus? // Prometheus?
Help: "Total number of requests to various endpoints", Help: "Total number of requests to various endpoints",
}, },
[]string{"method"}, []string{"method", "endpoint"},
) )
ErrorsCount = prometheus.NewCounterVec( ErrorsCount = prometheus.NewCounterVec(
prometheus.CounterOpts{ prometheus.CounterOpts{
Name: "wallet_sync_error_count", Name: "wallet_sync_error_count",
Help: "Total number of various kinds of errors", Help: "Total number of various kinds of errors",
}, },
[]string{"details"}, []string{"error_type"},
) )
) )

View file

@ -144,7 +144,7 @@ func (s *Server) changePassword(w http.ResponseWriter, req *http.Request) {
select { select {
case s.userRemove <- wsClientForUser{userId, nil}: case s.userRemove <- wsClientForUser{userId, nil}:
case <-timeout.C: 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 return
} }
timeout.Stop() timeout.Stop()

View file

@ -55,7 +55,7 @@ func (s *Server) handleWallet(w http.ResponseWriter, req *http.Request) {
} }
func (s *Server) getWallet(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) { if !getGetData(w, req) {
return return
@ -109,7 +109,7 @@ func (s *Server) getWallet(w http.ResponseWriter, req *http.Request) {
// current wallet's sequence // current wallet's sequence
// 500: Update unsuccessful for unanticipated reasons // 500: Update unsuccessful for unanticipated reasons
func (s *Server) postWallet(w http.ResponseWriter, req *http.Request) { 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 var walletRequest WalletRequest
if !getPostData(w, req, &walletRequest) { if !getPostData(w, req, &walletRequest) {
@ -155,7 +155,7 @@ func (s *Server) postWallet(w http.ResponseWriter, req *http.Request) {
select { select {
case s.walletUpdates <- walletUpdateMsg{authToken.UserId, walletRequest.Sequence}: case s.walletUpdates <- walletUpdateMsg{authToken.UserId, walletRequest.Sequence}:
case <-timeout.C: 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() timeout.Stop()
} }