Add RequestsBlocked stat counter

This commit is contained in:
Justin Li 2014-07-24 17:48:03 -04:00
parent 2779560934
commit 1a79bdeb6b
2 changed files with 8 additions and 0 deletions

View file

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

View file

@ -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++