Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-workhorse
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-workhorse
Commits
254e1220
Commit
254e1220
authored
Jun 09, 2017
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add prometheus counter for error page responses
parent
9af8b521
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
0 deletions
+17
-0
internal/staticpages/error_pages.go
internal/staticpages/error_pages.go
+17
-0
No files found.
internal/staticpages/error_pages.go
View file @
254e1220
...
...
@@ -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"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment