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 {
|
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
|
||||||
|
|
|
@ -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++
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue