mirror of
https://github.com/sot-tech/mochi.git
synced 2026-04-30 01:19:59 -07:00
Add RequestsBlocked stat counter
This commit is contained in:
@@ -44,6 +44,7 @@ func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprou
|
||||
|
||||
if err == models.ErrMalformedRequest {
|
||||
writer.WriteError(err)
|
||||
stats.RecordEvent(stats.BlockedRequest)
|
||||
return http.StatusOK, nil
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -53,6 +54,7 @@ func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprou
|
||||
|
||||
if err == models.ErrBadRequest {
|
||||
writer.WriteError(err)
|
||||
stats.RecordEvent(stats.BlockedRequest)
|
||||
return http.StatusOK, nil
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
@@ -68,6 +70,7 @@ func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request, p httproute
|
||||
|
||||
if err == models.ErrMalformedRequest {
|
||||
writer.WriteError(err)
|
||||
stats.RecordEvent(stats.BlockedRequest)
|
||||
return http.StatusOK, nil
|
||||
} else if err != nil {
|
||||
return http.StatusInternalServerError, err
|
||||
|
||||
@@ -32,6 +32,7 @@ const (
|
||||
ClosedConnection
|
||||
|
||||
HandledRequest
|
||||
BlockedRequest
|
||||
ErroredRequest
|
||||
|
||||
ResponseTime
|
||||
@@ -82,6 +83,7 @@ type Stats struct {
|
||||
|
||||
RequestsHandled uint64 `json:"requests_handled"`
|
||||
RequestsErrored uint64 `json:"requests_errored"`
|
||||
RequestsBlocked uint64 `json:"requests_blocked"`
|
||||
|
||||
ResponseTime PercentileTimes `json:"response_time"`
|
||||
MemStats *MemStatsWrapper `json:"mem,omitempty"`
|
||||
@@ -198,6 +200,9 @@ func (s *Stats) handleEvent(event int) {
|
||||
case HandledRequest:
|
||||
s.RequestsHandled++
|
||||
|
||||
case BlockedRequest:
|
||||
s.RequestsBlocked++
|
||||
|
||||
case ErroredRequest:
|
||||
s.RequestsErrored++
|
||||
|
||||
|
||||
Reference in New Issue
Block a user