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
bca495e2
Commit
bca495e2
authored
Nov 01, 2017
by
Wei Wei
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
rename metric reflector_xx_last_resource_version to reflector_last_resource_version{name="xx"}
parent
7f9f847c
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
10 deletions
+11
-10
prometheus.go
pkg/util/reflector/prometheus/prometheus.go
+8
-7
reflector.go
staging/src/k8s.io/client-go/tools/cache/reflector.go
+3
-3
No files found.
pkg/util/reflector/prometheus/prometheus.go
View file @
bca495e2
...
...
@@ -68,6 +68,12 @@ var (
Name
:
"items_per_watch"
,
Help
:
"How many items an API watch returns to the reflectors"
,
},
[]
string
{
"name"
})
lastResourceVersion
=
prometheus
.
NewGaugeVec
(
prometheus
.
GaugeOpts
{
Subsystem
:
reflectorSubsystem
,
Name
:
"last_resource_version"
,
Help
:
"Last resource version seen for the reflectors"
,
},
[]
string
{
"name"
})
)
func
init
()
{
...
...
@@ -78,6 +84,7 @@ func init() {
prometheus
.
MustRegister
(
shortWatchesTotal
)
prometheus
.
MustRegister
(
watchDuration
)
prometheus
.
MustRegister
(
itemsPerWatch
)
prometheus
.
MustRegister
(
lastResourceVersion
)
cache
.
SetReflectorMetricsProvider
(
prometheusMetricsProvider
{})
}
...
...
@@ -117,11 +124,5 @@ func (prometheusMetricsProvider) NewItemsInWatchMetric(name string) cache.Summar
}
func
(
prometheusMetricsProvider
)
NewLastResourceVersionMetric
(
name
string
)
cache
.
GaugeMetric
{
rv
:=
prometheus
.
NewGauge
(
prometheus
.
GaugeOpts
{
Subsystem
:
name
,
Name
:
"last_resource_version"
,
Help
:
"last resource version seen for the reflectors"
,
})
prometheus
.
MustRegister
(
rv
)
return
rv
return
lastResourceVersion
.
WithLabelValues
(
name
)
}
staging/src/k8s.io/client-go/tools/cache/reflector.go
View file @
bca495e2
...
...
@@ -109,7 +109,7 @@ func NewNamedReflector(name string, lw ListerWatcher, expectedType interface{},
r
:=
&
Reflector
{
name
:
name
,
// we need this to be unique per process (some names are still the same)but obvious who it belongs to
metrics
:
newReflectorMetrics
(
makeValidPromethusMetric
Name
(
fmt
.
Sprintf
(
"reflector_"
+
name
+
"_%d"
,
reflectorSuffix
))),
metrics
:
newReflectorMetrics
(
makeValidPromethusMetric
Label
(
fmt
.
Sprintf
(
"reflector_"
+
name
+
"_%d"
,
reflectorSuffix
))),
listerWatcher
:
lw
,
store
:
store
,
expectedType
:
reflect
.
TypeOf
(
expectedType
),
...
...
@@ -120,9 +120,9 @@ func NewNamedReflector(name string, lw ListerWatcher, expectedType interface{},
return
r
}
func
makeValidPromethusMetric
Name
(
in
string
)
string
{
func
makeValidPromethusMetric
Label
(
in
string
)
string
{
// this isn't perfect, but it removes our common characters
return
strings
.
NewReplacer
(
"/"
,
"_"
,
"."
,
"_"
,
"-"
,
"_"
)
.
Replace
(
in
)
return
strings
.
NewReplacer
(
"/"
,
"_"
,
"."
,
"_"
,
"-"
,
"_"
,
":"
,
"_"
)
.
Replace
(
in
)
}
// internalPackages are packages that ignored when creating a default reflector name. These packages are in the common
...
...
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