Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
k8s-ingress
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
3
Merge Requests
3
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
uplex-varnish
k8s-ingress
Commits
1ff7b034
Commit
1ff7b034
authored
Jan 15, 2019
by
Geoff Simmons
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use a counter vector for the watcher event counters.
parent
831b25c2
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
43 deletions
+19
-43
controller.go
pkg/controller/controller.go
+11
-13
metrics.go
pkg/controller/metrics.go
+8
-30
No files found.
pkg/controller/controller.go
View file @
1ff7b034
...
...
@@ -211,42 +211,40 @@ func (ingc *IngressController) logObj(action string, obj interface{}) {
}
}
func
incWatchCounter
(
obj
interface
{},
sync
Type
SyncType
)
{
func
incWatchCounter
(
obj
interface
{},
sync
string
)
{
switch
obj
.
(
type
)
{
case
*
extensions
.
Ingress
:
watchCounters
[
"Ingress"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"Ingress"
,
sync
)
.
Inc
()
case
*
api_v1
.
Service
:
watchCounters
[
"Service"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"Service"
,
sync
)
.
Inc
()
case
*
api_v1
.
Endpoints
:
watchCounters
[
"Endpoints"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"Endpoints"
,
sync
)
.
Inc
()
case
*
api_v1
.
Secret
:
watchCounters
[
"Secret"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"Secret"
,
sync
)
.
Inc
()
case
*
vcr_v1alpha1
.
VarnishConfig
:
watchCounters
[
"VarnishConfig"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"VarnishConfig"
,
sync
)
.
Inc
()
case
*
vcr_v1alpha1
.
BackendConfig
:
watchCounters
[
"BackendConfig"
][
syncType
]
.
Inc
()
watchCounters
.
WithLabelValues
(
"BackendConfig"
,
sync
)
.
Inc
()
default
:
err
:=
fmt
.
Errorf
(
"Unhandled type %T, watcher counter not "
+
"incremented"
,
obj
)
utilruntime
.
HandleError
(
err
)
watchCounters
.
WithLabelValues
(
"Unknown"
,
sync
)
.
Inc
()
}
}
func
(
ingc
*
IngressController
)
addObj
(
obj
interface
{})
{
ingc
.
logObj
(
"Add"
,
obj
)
incWatchCounter
(
obj
,
Add
)
incWatchCounter
(
obj
,
"Add"
)
ingc
.
nsQs
.
Queue
.
Add
(
&
SyncObj
{
Type
:
Add
,
Obj
:
obj
})
}
func
(
ingc
*
IngressController
)
deleteObj
(
obj
interface
{})
{
ingc
.
logObj
(
"Delete"
,
obj
)
incWatchCounter
(
obj
,
Delete
)
incWatchCounter
(
obj
,
"Delete"
)
ingc
.
nsQs
.
Queue
.
Add
(
&
SyncObj
{
Type
:
Delete
,
Obj
:
obj
})
}
func
(
ingc
*
IngressController
)
updateObj
(
old
,
new
interface
{})
{
ingc
.
log
.
Debug
(
"Update:"
,
old
,
new
)
incWatchCounter
(
new
,
Update
)
incWatchCounter
(
new
,
"Update"
)
oldMeta
,
oldErr
:=
meta
.
Accessor
(
old
)
newMeta
,
newErr
:=
meta
.
Accessor
(
new
)
t
,
tErr
:=
meta
.
TypeAccessor
(
old
)
...
...
pkg/controller/metrics.go
View file @
1ff7b034
...
...
@@ -120,14 +120,13 @@ func (_ promProvider) NewRetriesMetric(name string) workqueue.CounterMetric {
}
var
(
watchCounters
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
=
map
[
string
]
map
[
SyncType
]
prometheus
.
Counter
{
"Ingress"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Service"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Endpoints"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"Secret"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"VarnishConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
"BackendConfig"
:
make
(
map
[
SyncType
]
prometheus
.
Counter
),
}
watchCounters
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Subsystem
:
"watcher"
,
Namespace
:
namespace
,
Name
:
"events_total"
,
Help
:
"Total number of watcher API events"
,
},
[]
string
{
"kind"
,
"event"
})
syncCounters
=
prometheus
.
NewCounterVec
(
prometheus
.
CounterOpts
{
Namespace
:
namespace
,
Subsystem
:
"sync"
,
...
...
@@ -138,28 +137,7 @@ var (
func
InitMetrics
()
{
workqueue
.
SetProvider
(
promProvider
{})
syncLabels
:=
map
[
SyncType
]
string
{
Add
:
"add"
,
Update
:
"update"
,
Delete
:
"delete"
,
}
for
kind
,
m
:=
range
watchCounters
{
for
syncType
,
typeLabel
:=
range
syncLabels
{
labels
:=
make
(
map
[
string
]
string
)
labels
[
"kind"
]
=
kind
labels
[
"event"
]
=
typeLabel
m
[
syncType
]
=
prometheus
.
NewCounter
(
prometheus
.
CounterOpts
{
Subsystem
:
"watcher"
,
Namespace
:
namespace
,
Name
:
"events_total"
,
Help
:
"Total number of watcher "
+
"API events"
,
ConstLabels
:
labels
,
})
prometheus
.
Register
(
m
[
syncType
])
}
}
prometheus
.
Register
(
watchCounters
)
prometheus
.
Register
(
syncCounters
)
}
...
...
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