Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
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-ce
Commits
67caa789
Commit
67caa789
authored
Nov 25, 2016
by
Jacob Vosmaer
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Remove 'metrics' package, rename metrics
parent
b9169287
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
29 deletions
+26
-29
internal/helper/logging.go
internal/helper/logging.go
+26
-5
internal/metrics/metrics.go
internal/metrics/metrics.go
+0
-24
No files found.
internal/helper/logging.go
View file @
67caa789
...
...
@@ -9,19 +9,40 @@ import (
"strconv"
"time"
"git
lab.com/gitlab-org/gitlab-workhorse/internal/metric
s"
"git
hub.com/prometheus/client_golang/prometheu
s"
)
var
responseLogger
*
log
.
Logger
var
(
responseLogger
*
log
.
Logger
sessionsActive
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"gitlab_workhorse_http_sessions_active"
,
Help
:
"Number of HTTP request-response cycles currently being handled by gitlab-workhorse."
,
})
requestsTotal
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"gitlab_workhorse_http_requests_total"
,
Help
:
"How many HTTP requests have been processed by gitlab-workhorse, partitioned by status code and HTTP method."
,
},
[]
string
{
"code"
,
"method"
},
)
)
func
init
()
{
SetCustomResponseLogger
(
os
.
Stderr
)
registerPrometheusMetrics
()
}
func
SetCustomResponseLogger
(
writer
io
.
Writer
)
{
responseLogger
=
log
.
New
(
writer
,
""
,
0
)
}
func
registerPrometheusMetrics
()
{
prometheus
.
MustRegister
(
sessionsActive
)
prometheus
.
MustRegister
(
requestsTotal
)
}
type
LoggingResponseWriter
struct
{
rw
http
.
ResponseWriter
status
int
...
...
@@ -30,7 +51,7 @@ type LoggingResponseWriter struct {
}
func
NewLoggingResponseWriter
(
rw
http
.
ResponseWriter
)
LoggingResponseWriter
{
metrics
.
Request
sActive
.
Inc
()
session
sActive
.
Inc
()
return
LoggingResponseWriter
{
rw
:
rw
,
started
:
time
.
Now
(),
...
...
@@ -67,6 +88,6 @@ func (l *LoggingResponseWriter) Log(r *http.Request) {
l
.
status
,
l
.
written
,
r
.
Referer
(),
r
.
UserAgent
(),
duration
.
Seconds
(),
)
metrics
.
Request
sActive
.
Dec
()
metrics
.
R
equestsTotal
.
WithLabelValues
(
strconv
.
Itoa
(
l
.
status
),
r
.
Method
)
.
Inc
()
session
sActive
.
Dec
()
r
equestsTotal
.
WithLabelValues
(
strconv
.
Itoa
(
l
.
status
),
r
.
Method
)
.
Inc
()
}
internal/metrics/metrics.go
deleted
100644 → 0
View file @
b9169287
package
metrics
import
(
"github.com/prometheus/client_golang/prometheus"
)
var
(
RequestsActive
=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Name
:
"gitlab_workhorse_requests_active"
,
Help
:
"Number of HTTP requests currently being handled by gitlab-workhorse."
,
})
RequestsTotal
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Name
:
"gitlab_workhorse_requests_total"
,
Help
:
"How many HTTP requests have been processed by gitlab-workhorse, partitioned by status code and HTTP method."
,
},
[]
string
{
"code"
,
"method"
},
)
)
func
init
()
{
prometheus
.
MustRegister
(
RequestsActive
)
prometheus
.
MustRegister
(
RequestsTotal
)
}
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