Commit 254e1220 authored by Jacob Vosmaer's avatar Jacob Vosmaer

Add prometheus counter for error page responses

parent 9af8b521
......@@ -7,8 +7,24 @@ import (
"path/filepath"
"gitlab.com/gitlab-org/gitlab-workhorse/internal/helper"
"github.com/prometheus/client_golang/prometheus"
)
var (
staticErrorResponses = prometheus.NewCounterVec(
prometheus.CounterOpts{
Name: "gitlab_workhorse_static_error_responses",
Help: "How many HTTP responses have been changed to a static error page, by HTTP status code.",
},
[]string{"code"},
)
)
func init() {
prometheus.MustRegister(staticErrorResponses)
}
type errorPageResponseWriter struct {
rw http.ResponseWriter
status int
......@@ -43,6 +59,7 @@ func (s *errorPageResponseWriter) WriteHeader(status int) {
// check if custom error page exists, serve this page instead
if data, err := ioutil.ReadFile(errorPageFile); err == nil {
s.hijacked = true
staticErrorResponses.WithLabelValues(fmt.Sprintf("%d", s.status)).Inc()
helper.SetNoCacheHeaders(s.rw.Header())
s.rw.Header().Set("Content-Type", "text/html; charset=utf-8")
......
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