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?
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"},
)
)

View file

@ -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()

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) {
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()
}