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
d1522d6a
Commit
d1522d6a
authored
Jul 24, 2017
by
Ben Kochie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Extract instrumentDuration function.
Apply `instrumentDuration()` to both `route()` and `wsRoute()`.
parent
98929304
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
10 additions
and
9 deletions
+10
-9
internal/upstream/routes.go
internal/upstream/routes.go
+10
-9
No files found.
internal/upstream/routes.go
View file @
d1522d6a
...
...
@@ -63,18 +63,19 @@ func compileRegexp(regexpStr string) *regexp.Regexp {
return
regexp
.
MustCompile
(
regexpStr
)
}
func
route
(
method
,
regexpStr
string
,
handler
http
.
Handler
,
matchers
...
matcherFunc
)
routeEntry
{
instr
:=
func
(
h
http
.
Handler
)
http
.
Handler
{
func
instrumentDuration
(
h
http
.
Handler
,
method
string
,
regexpStr
string
)
http
.
Handler
{
return
http
.
HandlerFunc
(
func
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
start
:=
time
.
Now
()
h
.
ServeHTTP
(
w
,
r
)
routeRequestDurations
.
WithLabelValues
(
method
,
regexpStr
)
.
Observe
(
time
.
Since
(
start
)
.
Seconds
())
})
}
}
func
route
(
method
,
regexpStr
string
,
handler
http
.
Handler
,
matchers
...
matcherFunc
)
routeEntry
{
return
routeEntry
{
method
:
method
,
regex
:
compileRegexp
(
regexpStr
),
handler
:
instr
(
denyWebsocket
(
handler
)
),
handler
:
instr
umentDuration
(
denyWebsocket
(
handler
),
method
,
regexpStr
),
matchers
:
matchers
,
}
}
...
...
@@ -83,7 +84,7 @@ func wsRoute(regexpStr string, handler http.Handler, matchers ...matcherFunc) ro
return
routeEntry
{
method
:
"GET"
,
regex
:
compileRegexp
(
regexpStr
),
handler
:
handler
,
handler
:
instrumentDuration
(
handler
,
"GET"
,
regexpStr
)
,
matchers
:
append
(
matchers
,
websocket
.
IsWebSocketUpgrade
),
}
}
...
...
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