Skip to content

Commit

Permalink
better prometheus tags
Browse files Browse the repository at this point in the history
  • Loading branch information
orblivion committed Sep 21, 2022
1 parent a82a4e7 commit afc43a0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions metrics/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"},
)
)

Expand Down
2 changes: 1 addition & 1 deletion server/password.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
6 changes: 3 additions & 3 deletions server/wallet.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
}

0 comments on commit afc43a0

Please sign in to comment.