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 { if err == models.ErrMalformedRequest {
writer.WriteError(err) writer.WriteError(err)
stats.RecordEvent(stats.BlockedRequest)
return http.StatusOK, nil return http.StatusOK, nil
} else if err != nil { } else if err != nil {
return http.StatusInternalServerError, err return http.StatusInternalServerError, err
@ -53,6 +54,7 @@ func (s *Server) serveAnnounce(w http.ResponseWriter, r *http.Request, p httprou
if err == models.ErrBadRequest { if err == models.ErrBadRequest {
writer.WriteError(err) writer.WriteError(err)
stats.RecordEvent(stats.BlockedRequest)
return http.StatusOK, nil return http.StatusOK, nil
} else if err != nil { } else if err != nil {
return http.StatusInternalServerError, err return http.StatusInternalServerError, err
@ -68,6 +70,7 @@ func (s *Server) serveScrape(w http.ResponseWriter, r *http.Request, p httproute
if err == models.ErrMalformedRequest { if err == models.ErrMalformedRequest {
writer.WriteError(err) writer.WriteError(err)
stats.RecordEvent(stats.BlockedRequest)
return http.StatusOK, nil return http.StatusOK, nil
} else if err != nil { } else if err != nil {
return http.StatusInternalServerError, err return http.StatusInternalServerError, err

View file

@ -32,6 +32,7 @@ const (
ClosedConnection ClosedConnection
HandledRequest HandledRequest
BlockedRequest
ErroredRequest ErroredRequest
ResponseTime ResponseTime
@ -82,6 +83,7 @@ type Stats struct {
RequestsHandled uint64 `json:"requests_handled"` RequestsHandled uint64 `json:"requests_handled"`
RequestsErrored uint64 `json:"requests_errored"` RequestsErrored uint64 `json:"requests_errored"`
RequestsBlocked uint64 `json:"requests_blocked"`
ResponseTime PercentileTimes `json:"response_time"` ResponseTime PercentileTimes `json:"response_time"`
MemStats *MemStatsWrapper `json:"mem,omitempty"` MemStats *MemStatsWrapper `json:"mem,omitempty"`
@ -198,6 +200,9 @@ func (s *Stats) handleEvent(event int) {
case HandledRequest: case HandledRequest:
s.RequestsHandled++ s.RequestsHandled++
case BlockedRequest:
s.RequestsBlocked++
case ErroredRequest: case ErroredRequest:
s.RequestsErrored++ s.RequestsErrored++