Add RequestsBlocked stat counter
This commit is contained in:
parent
2779560934
commit
1a79bdeb6b
2 changed files with 8 additions and 0 deletions
|
@ -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++
|
||||
|
||||
|
|
Loading…
Reference in a new issue