Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
K
k3s
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Jacklull
k3s
Commits
05ea93f9
Commit
05ea93f9
authored
Mar 06, 2015
by
Daniel Smith
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #5147 from a-robinson/func
Re-add the defer statements around the monitor() calls in the apiserver.
parents
a858c742
60f0e9d6
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
11 additions
and
8 deletions
+11
-8
apiserver.go
pkg/apiserver/apiserver.go
+5
-4
proxy.go
pkg/apiserver/proxy.go
+1
-1
redirect.go
pkg/apiserver/redirect.go
+1
-1
validator.go
pkg/apiserver/validator.go
+3
-1
watch.go
pkg/apiserver/watch.go
+1
-1
No files found.
pkg/apiserver/apiserver.go
View file @
05ea93f9
...
...
@@ -70,9 +70,9 @@ func init() {
// monitor is a helper function for each HTTP request handler to use for
// instrumenting basic request counter and latency metrics.
func
monitor
(
handler
,
verb
,
resource
string
,
httpCode
int
,
reqStart
time
.
Time
)
{
requestCounter
.
WithLabelValues
(
handler
,
verb
,
resource
,
strconv
.
Itoa
(
httpCode
))
.
Inc
()
requestLatencies
.
WithLabelValues
(
handler
,
verb
)
.
Observe
(
float64
((
time
.
Since
(
reqStart
))
/
time
.
Microsecond
))
func
monitor
(
handler
string
,
verb
,
resource
*
string
,
httpCode
*
int
,
reqStart
time
.
Time
)
{
requestCounter
.
WithLabelValues
(
handler
,
*
verb
,
*
resource
,
strconv
.
Itoa
(
*
httpCode
))
.
Inc
()
requestLatencies
.
WithLabelValues
(
handler
,
*
verb
)
.
Observe
(
float64
((
time
.
Since
(
reqStart
))
/
time
.
Microsecond
))
}
// monitorFilter creates a filter that reports the metrics for a given resource and action.
...
...
@@ -80,7 +80,8 @@ func monitorFilter(action, resource string) restful.FilterFunction {
return
func
(
req
*
restful
.
Request
,
res
*
restful
.
Response
,
chain
*
restful
.
FilterChain
)
{
reqStart
:=
time
.
Now
()
chain
.
ProcessFilter
(
req
,
res
)
monitor
(
"rest"
,
action
,
resource
,
res
.
StatusCode
(),
reqStart
)
httpCode
:=
res
.
StatusCode
()
monitor
(
"rest"
,
&
action
,
&
resource
,
&
httpCode
,
reqStart
)
}
}
...
...
pkg/apiserver/proxy.go
View file @
05ea93f9
...
...
@@ -90,7 +90,7 @@ func (r *ProxyHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
var
apiResource
string
var
httpCode
int
reqStart
:=
time
.
Now
()
defer
monitor
(
"proxy"
,
verb
,
apiResource
,
httpCode
,
reqStart
)
defer
monitor
(
"proxy"
,
&
verb
,
&
apiResource
,
&
httpCode
,
reqStart
)
requestInfo
,
err
:=
r
.
apiRequestInfoResolver
.
GetAPIRequestInfo
(
req
)
if
err
!=
nil
{
...
...
pkg/apiserver/redirect.go
View file @
05ea93f9
...
...
@@ -39,7 +39,7 @@ func (r *RedirectHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
var
apiResource
string
var
httpCode
int
reqStart
:=
time
.
Now
()
defer
monitor
(
"redirect"
,
verb
,
apiResource
,
httpCode
,
reqStart
)
defer
monitor
(
"redirect"
,
&
verb
,
&
apiResource
,
&
httpCode
,
reqStart
)
requestInfo
,
err
:=
r
.
apiRequestInfoResolver
.
GetAPIRequestInfo
(
req
)
if
err
!=
nil
{
...
...
pkg/apiserver/validator.go
View file @
05ea93f9
...
...
@@ -73,9 +73,11 @@ type ServerStatus struct {
}
func
(
v
*
validator
)
ServeHTTP
(
w
http
.
ResponseWriter
,
r
*
http
.
Request
)
{
verb
:=
"get"
apiResource
:=
""
var
httpCode
int
reqStart
:=
time
.
Now
()
defer
monitor
(
"validate"
,
"get"
,
""
,
httpCode
,
reqStart
)
defer
monitor
(
"validate"
,
&
verb
,
&
apiResource
,
&
httpCode
,
reqStart
)
reply
:=
[]
ServerStatus
{}
for
name
,
server
:=
range
v
.
servers
()
{
...
...
pkg/apiserver/watch.go
View file @
05ea93f9
...
...
@@ -66,7 +66,7 @@ func (h *WatchHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
var
apiResource
string
var
httpCode
int
reqStart
:=
time
.
Now
()
defer
monitor
(
"watch"
,
verb
,
apiResource
,
httpCode
,
reqStart
)
defer
monitor
(
"watch"
,
&
verb
,
&
apiResource
,
&
httpCode
,
reqStart
)
if
req
.
Method
!=
"GET"
{
notFound
(
w
,
req
)
...
...
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