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
bdd9492d
Commit
bdd9492d
authored
May 14, 2018
by
wojtekt
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Track number of registered watchers in apiserver
parent
e34df0a2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
0 deletions
+14
-0
watch.go
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
+5
-0
metrics.go
...ing/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
+9
-0
No files found.
staging/src/k8s.io/apiserver/pkg/endpoints/handlers/watch.go
View file @
bdd9492d
...
@@ -30,6 +30,7 @@ import (
...
@@ -30,6 +30,7 @@ import (
utilruntime
"k8s.io/apimachinery/pkg/util/runtime"
utilruntime
"k8s.io/apimachinery/pkg/util/runtime"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apimachinery/pkg/watch"
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
"k8s.io/apiserver/pkg/endpoints/handlers/negotiation"
"k8s.io/apiserver/pkg/endpoints/metrics"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/endpoints/request"
"k8s.io/apiserver/pkg/server/httplog"
"k8s.io/apiserver/pkg/server/httplog"
"k8s.io/apiserver/pkg/util/wsstream"
"k8s.io/apiserver/pkg/util/wsstream"
...
@@ -140,6 +141,10 @@ type WatchServer struct {
...
@@ -140,6 +141,10 @@ type WatchServer struct {
// ServeHTTP serves a series of encoded events via HTTP with Transfer-Encoding: chunked
// ServeHTTP serves a series of encoded events via HTTP with Transfer-Encoding: chunked
// or over a websocket connection.
// or over a websocket connection.
func
(
s
*
WatchServer
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
func
(
s
*
WatchServer
)
ServeHTTP
(
w
http
.
ResponseWriter
,
req
*
http
.
Request
)
{
kind
:=
s
.
Scope
.
Kind
metrics
.
RegisteredWatchers
.
WithLabelValues
(
kind
.
Group
,
kind
.
Version
,
kind
.
Kind
)
.
Inc
()
defer
metrics
.
RegisteredWatchers
.
WithLabelValues
(
kind
.
Group
,
kind
.
Version
,
kind
.
Kind
)
.
Dec
()
w
=
httplog
.
Unlogged
(
w
)
w
=
httplog
.
Unlogged
(
w
)
if
wsstream
.
IsWebSocketRequest
(
req
)
{
if
wsstream
.
IsWebSocketRequest
(
req
)
{
...
...
staging/src/k8s.io/apiserver/pkg/endpoints/metrics/metrics.go
View file @
bdd9492d
...
@@ -93,6 +93,14 @@ var (
...
@@ -93,6 +93,14 @@ var (
},
},
[]
string
{
"requestKind"
},
[]
string
{
"requestKind"
},
)
)
// RegisteredWatchers is a number of currently registered watchers splitted by resource.
RegisteredWatchers
=
prometheus
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Name
:
"apiserver_registered_watchers"
,
Help
:
"Number of currently registered watchers for a given resources"
,
},
[]
string
{
"group"
,
"version"
,
"kind"
},
)
// Because of volatality of the base metric this is pre-aggregated one. Instead of reporing current usage all the time
// Because of volatality of the base metric this is pre-aggregated one. Instead of reporing current usage all the time
// it reports maximal usage during the last second.
// it reports maximal usage during the last second.
currentInflightRequests
=
prometheus
.
NewGaugeVec
(
currentInflightRequests
=
prometheus
.
NewGaugeVec
(
...
@@ -111,6 +119,7 @@ var (
...
@@ -111,6 +119,7 @@ var (
requestLatenciesSummary
,
requestLatenciesSummary
,
responseSizes
,
responseSizes
,
DroppedRequests
,
DroppedRequests
,
RegisteredWatchers
,
currentInflightRequests
,
currentInflightRequests
,
}
}
)
)
...
...
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