Commit e798a664 authored by Jacob Vosmaer (GitLab)'s avatar Jacob Vosmaer (GitLab)

Merge branch 'errTooManyRequests-to-prometheus' into 'master'

Track errTooManyRequests in prometheus

Closes #106

See merge request !127
parents b0ffe176 ddc3eab1
......@@ -28,18 +28,6 @@ func LogError(r *http.Request, err error) {
printError(r, err)
}
func ServiceUnavailable(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, "Service Unavailable", http.StatusServiceUnavailable)
captureRavenError(r, err)
printError(r, err)
}
func TooManyRequests(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, "Too Many Requests", 429) // http.StatusTooManyRequests was added in go1.6
captureRavenError(r, err)
printError(r, err)
}
func RequestEntityTooLarge(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, "Request Entity Too Large", http.StatusRequestEntityTooLarge)
captureRavenError(r, err)
......
......@@ -7,7 +7,10 @@ import (
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
)
const DefaultTimeout = 30 * time.Second
const (
DefaultTimeout = 30 * time.Second
httpStatusTooManyRequests = 429
)
// QueueRequests creates a new request queue
// name specifies the name of queue, used to label Prometheus metrics
......@@ -35,10 +38,10 @@ func QueueRequests(name string, h http.Handler, limit, queueLimit uint, queueTim
h.ServeHTTP(w, r)
case ErrTooManyRequests:
helper.TooManyRequests(w, r, err)
http.Error(w, "Too Many Requests", httpStatusTooManyRequests)
case ErrQueueingTimedout:
helper.ServiceUnavailable(w, r, err)
http.Error(w, "Service Unavailable", http.StatusServiceUnavailable)
default:
helper.Fail500(w, r, err)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment