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
578962d9
Commit
578962d9
authored
Nov 10, 2018
by
Daniel Smith
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fixup! Test workqueue metrics
change units to seconds
parent
44a87baf
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
17 deletions
+22
-17
prometheus.go
pkg/util/workqueue/prometheus/prometheus.go
+6
-3
metrics.go
staging/src/k8s.io/client-go/util/workqueue/metrics.go
+14
-12
metrics_test.go
staging/src/k8s.io/client-go/util/workqueue/metrics_test.go
+2
-2
No files found.
pkg/util/workqueue/prometheus/prometheus.go
View file @
578962d9
...
@@ -71,11 +71,14 @@ func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.Su
...
@@ -71,11 +71,14 @@ func (prometheusMetricsProvider) NewWorkDurationMetric(name string) workqueue.Su
return
workDuration
return
workDuration
}
}
func
(
prometheusMetricsProvider
)
NewUnfinishedWork
Micros
econdsMetric
(
name
string
)
workqueue
.
SettableGaugeMetric
{
func
(
prometheusMetricsProvider
)
NewUnfinishedWork
S
econdsMetric
(
name
string
)
workqueue
.
SettableGaugeMetric
{
unfinished
:=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
unfinished
:=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
name
,
Subsystem
:
name
,
Name
:
"unfinished_work_microseconds"
,
Name
:
"unfinished_work_seconds"
,
Help
:
"How many microseconds of work has "
+
name
+
" done that is still in progress and hasn't yet been observed by work_duration."
,
Help
:
"How many seconds of work "
+
name
+
" has done that "
+
"is in progress and hasn't been observed by work_duration. Large "
+
"values indicate stuck threads. One can deduce the number of stuck "
+
"threads by observing the rate at which this increases."
,
})
})
prometheus
.
Register
(
unfinished
)
prometheus
.
Register
(
unfinished
)
return
unfinished
return
unfinished
...
...
staging/src/k8s.io/client-go/util/workqueue/metrics.go
View file @
578962d9
...
@@ -80,7 +80,7 @@ type defaultQueueMetrics struct {
...
@@ -80,7 +80,7 @@ type defaultQueueMetrics struct {
processingStartTimes
map
[
t
]
time
.
Time
processingStartTimes
map
[
t
]
time
.
Time
// how long have current threads been working?
// how long have current threads been working?
unfinishedWork
Micros
econds
SettableGaugeMetric
unfinishedWork
S
econds
SettableGaugeMetric
}
}
func
(
m
*
defaultQueueMetrics
)
add
(
item
t
)
{
func
(
m
*
defaultQueueMetrics
)
add
(
item
t
)
{
...
@@ -124,7 +124,9 @@ func (m *defaultQueueMetrics) updateUnfinishedWork() {
...
@@ -124,7 +124,9 @@ func (m *defaultQueueMetrics) updateUnfinishedWork() {
for
_
,
t
:=
range
m
.
processingStartTimes
{
for
_
,
t
:=
range
m
.
processingStartTimes
{
total
+=
m
.
sinceInMicroseconds
(
t
)
total
+=
m
.
sinceInMicroseconds
(
t
)
}
}
m
.
unfinishedWorkMicroseconds
.
Set
(
total
)
// Convert to seconds; microseconds is unhelpfully granular for this.
total
/=
1000000
m
.
unfinishedWorkSeconds
.
Set
(
total
)
}
}
type
noMetrics
struct
{}
type
noMetrics
struct
{}
...
@@ -161,7 +163,7 @@ type MetricsProvider interface {
...
@@ -161,7 +163,7 @@ type MetricsProvider interface {
NewAddsMetric
(
name
string
)
CounterMetric
NewAddsMetric
(
name
string
)
CounterMetric
NewLatencyMetric
(
name
string
)
SummaryMetric
NewLatencyMetric
(
name
string
)
SummaryMetric
NewWorkDurationMetric
(
name
string
)
SummaryMetric
NewWorkDurationMetric
(
name
string
)
SummaryMetric
NewUnfinishedWork
Micros
econdsMetric
(
name
string
)
SettableGaugeMetric
NewUnfinishedWork
S
econdsMetric
(
name
string
)
SettableGaugeMetric
NewRetriesMetric
(
name
string
)
CounterMetric
NewRetriesMetric
(
name
string
)
CounterMetric
}
}
...
@@ -183,7 +185,7 @@ func (_ noopMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
...
@@ -183,7 +185,7 @@ func (_ noopMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
return
noopMetric
{}
return
noopMetric
{}
}
}
func
(
_
noopMetricsProvider
)
NewUnfinishedWork
Micros
econdsMetric
(
name
string
)
SettableGaugeMetric
{
func
(
_
noopMetricsProvider
)
NewUnfinishedWork
S
econdsMetric
(
name
string
)
SettableGaugeMetric
{
return
noopMetric
{}
return
noopMetric
{}
}
}
...
@@ -213,14 +215,14 @@ func (f *queueMetricsFactory) newQueueMetrics(name string, clock clock.Clock) qu
...
@@ -213,14 +215,14 @@ func (f *queueMetricsFactory) newQueueMetrics(name string, clock clock.Clock) qu
return
noMetrics
{}
return
noMetrics
{}
}
}
return
&
defaultQueueMetrics
{
return
&
defaultQueueMetrics
{
clock
:
clock
,
clock
:
clock
,
depth
:
mp
.
NewDepthMetric
(
name
),
depth
:
mp
.
NewDepthMetric
(
name
),
adds
:
mp
.
NewAddsMetric
(
name
),
adds
:
mp
.
NewAddsMetric
(
name
),
latency
:
mp
.
NewLatencyMetric
(
name
),
latency
:
mp
.
NewLatencyMetric
(
name
),
workDuration
:
mp
.
NewWorkDurationMetric
(
name
),
workDuration
:
mp
.
NewWorkDurationMetric
(
name
),
unfinishedWork
Microseconds
:
mp
.
NewUnfinishedWorkMicros
econdsMetric
(
name
),
unfinishedWork
Seconds
:
mp
.
NewUnfinishedWorkS
econdsMetric
(
name
),
addTimes
:
map
[
t
]
time
.
Time
{},
addTimes
:
map
[
t
]
time
.
Time
{},
processingStartTimes
:
map
[
t
]
time
.
Time
{},
processingStartTimes
:
map
[
t
]
time
.
Time
{},
}
}
}
}
...
...
staging/src/k8s.io/client-go/util/workqueue/metrics_test.go
View file @
578962d9
...
@@ -113,7 +113,7 @@ func (m *testMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
...
@@ -113,7 +113,7 @@ func (m *testMetricsProvider) NewWorkDurationMetric(name string) SummaryMetric {
return
&
m
.
duration
return
&
m
.
duration
}
}
func
(
m
*
testMetricsProvider
)
NewUnfinishedWork
Micros
econdsMetric
(
name
string
)
SettableGaugeMetric
{
func
(
m
*
testMetricsProvider
)
NewUnfinishedWork
S
econdsMetric
(
name
string
)
SettableGaugeMetric
{
return
&
m
.
unfinished
return
&
m
.
unfinished
}
}
...
@@ -229,7 +229,7 @@ func TestMetrics(t *testing.T) {
...
@@ -229,7 +229,7 @@ func TestMetrics(t *testing.T) {
c
.
Step
(
time
.
Millisecond
)
c
.
Step
(
time
.
Millisecond
)
<-
ch
<-
ch
mp
.
unfinished
.
notifyCh
=
nil
mp
.
unfinished
.
notifyCh
=
nil
if
e
,
a
:=
1000.0
,
mp
.
unfinished
.
gaugeValue
();
e
!=
a
{
if
e
,
a
:=
.001
,
mp
.
unfinished
.
gaugeValue
();
e
!=
a
{
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
t
.
Errorf
(
"expected %v, got %v"
,
e
,
a
)
}
}
...
...
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