Skip to content

Commit a12aac0

Browse files
committed
remove no-op clientgo reflector metrics
1 parent 4e6a39f commit a12aac0

File tree

1 file changed

+0
-120
lines changed

1 file changed

+0
-120
lines changed

pkg/metrics/client_go_adapter.go

Lines changed: 0 additions & 120 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import (
2222
"time"
2323

2424
"github.com/prometheus/client_golang/prometheus"
25-
reflectormetrics "k8s.io/client-go/tools/cache"
2625
clientmetrics "k8s.io/client-go/tools/metrics"
2726
)
2827

@@ -37,19 +36,6 @@ const (
3736
ResultKey = "requests_total"
3837
)
3938

40-
// Metrics subsystem and all keys used by the reflectors.
41-
const (
42-
ReflectorSubsystem = "reflector"
43-
ListsTotalKey = "lists_total"
44-
ListsDurationKey = "list_duration_seconds"
45-
ItemsPerListKey = "items_per_list"
46-
WatchesTotalKey = "watches_total"
47-
ShortWatchesTotalKey = "short_watches_total"
48-
WatchDurationKey = "watch_duration_seconds"
49-
ItemsPerWatchKey = "items_per_watch"
50-
LastResourceVersionKey = "last_resource_version"
51-
)
52-
5339
var (
5440
// client metrics.
5541

@@ -81,64 +67,10 @@ var (
8167
Name: ResultKey,
8268
Help: "Number of HTTP requests, partitioned by status code, method, and host.",
8369
}, []string{"code", "method", "host"})
84-
85-
// reflector metrics.
86-
87-
// TODO(directxman12): update these to be histograms once the metrics overhaul KEP
88-
// PRs start landing.
89-
90-
listsTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
91-
Subsystem: ReflectorSubsystem,
92-
Name: ListsTotalKey,
93-
Help: "Total number of API lists done by the reflectors",
94-
}, []string{"name"})
95-
96-
listsDuration = prometheus.NewSummaryVec(prometheus.SummaryOpts{
97-
Subsystem: ReflectorSubsystem,
98-
Name: ListsDurationKey,
99-
Help: "How long an API list takes to return and decode for the reflectors",
100-
}, []string{"name"})
101-
102-
itemsPerList = prometheus.NewSummaryVec(prometheus.SummaryOpts{
103-
Subsystem: ReflectorSubsystem,
104-
Name: ItemsPerListKey,
105-
Help: "How many items an API list returns to the reflectors",
106-
}, []string{"name"})
107-
108-
watchesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
109-
Subsystem: ReflectorSubsystem,
110-
Name: WatchesTotalKey,
111-
Help: "Total number of API watches done by the reflectors",
112-
}, []string{"name"})
113-
114-
shortWatchesTotal = prometheus.NewCounterVec(prometheus.CounterOpts{
115-
Subsystem: ReflectorSubsystem,
116-
Name: ShortWatchesTotalKey,
117-
Help: "Total number of short API watches done by the reflectors",
118-
}, []string{"name"})
119-
120-
watchDuration = prometheus.NewSummaryVec(prometheus.SummaryOpts{
121-
Subsystem: ReflectorSubsystem,
122-
Name: WatchDurationKey,
123-
Help: "How long an API watch takes to return and decode for the reflectors",
124-
}, []string{"name"})
125-
126-
itemsPerWatch = prometheus.NewSummaryVec(prometheus.SummaryOpts{
127-
Subsystem: ReflectorSubsystem,
128-
Name: ItemsPerWatchKey,
129-
Help: "How many items an API watch returns to the reflectors",
130-
}, []string{"name"})
131-
132-
lastResourceVersion = prometheus.NewGaugeVec(prometheus.GaugeOpts{
133-
Subsystem: ReflectorSubsystem,
134-
Name: LastResourceVersionKey,
135-
Help: "Last resource version seen for the reflectors",
136-
}, []string{"name"})
13770
)
13871

13972
func init() {
14073
registerClientMetrics()
141-
registerReflectorMetrics()
14274
}
14375

14476
// registerClientMetrics sets up the client latency metrics from client-go.
@@ -152,20 +84,6 @@ func registerClientMetrics() {
15284
})
15385
}
15486

155-
// registerReflectorMetrics sets up reflector (reconcile) loop metrics.
156-
func registerReflectorMetrics() {
157-
Registry.MustRegister(listsTotal)
158-
Registry.MustRegister(listsDuration)
159-
Registry.MustRegister(itemsPerList)
160-
Registry.MustRegister(watchesTotal)
161-
Registry.MustRegister(shortWatchesTotal)
162-
Registry.MustRegister(watchDuration)
163-
Registry.MustRegister(itemsPerWatch)
164-
Registry.MustRegister(lastResourceVersion)
165-
166-
reflectormetrics.SetReflectorMetricsProvider(reflectorMetricsProvider{})
167-
}
168-
16987
// this section contains adapters, implementations, and other sundry organic, artisanally
17088
// hand-crafted syntax trees required to convince client-go that it actually wants to let
17189
// someone use its metrics.
@@ -191,41 +109,3 @@ type resultAdapter struct {
191109
func (r *resultAdapter) Increment(_ context.Context, code, method, host string) {
192110
r.metric.WithLabelValues(code, method, host).Inc()
193111
}
194-
195-
// Reflector metrics provider (method #2 for client-go metrics),
196-
// copied (more-or-less directly) from k8s.io/kubernetes setup code
197-
// (which isn't anywhere in an easily-importable place).
198-
199-
type reflectorMetricsProvider struct{}
200-
201-
func (reflectorMetricsProvider) NewListsMetric(name string) reflectormetrics.CounterMetric {
202-
return listsTotal.WithLabelValues(name)
203-
}
204-
205-
func (reflectorMetricsProvider) NewListDurationMetric(name string) reflectormetrics.SummaryMetric {
206-
return listsDuration.WithLabelValues(name)
207-
}
208-
209-
func (reflectorMetricsProvider) NewItemsInListMetric(name string) reflectormetrics.SummaryMetric {
210-
return itemsPerList.WithLabelValues(name)
211-
}
212-
213-
func (reflectorMetricsProvider) NewWatchesMetric(name string) reflectormetrics.CounterMetric {
214-
return watchesTotal.WithLabelValues(name)
215-
}
216-
217-
func (reflectorMetricsProvider) NewShortWatchesMetric(name string) reflectormetrics.CounterMetric {
218-
return shortWatchesTotal.WithLabelValues(name)
219-
}
220-
221-
func (reflectorMetricsProvider) NewWatchDurationMetric(name string) reflectormetrics.SummaryMetric {
222-
return watchDuration.WithLabelValues(name)
223-
}
224-
225-
func (reflectorMetricsProvider) NewItemsInWatchMetric(name string) reflectormetrics.SummaryMetric {
226-
return itemsPerWatch.WithLabelValues(name)
227-
}
228-
229-
func (reflectorMetricsProvider) NewLastResourceVersionMetric(name string) reflectormetrics.GaugeMetric {
230-
return lastResourceVersion.WithLabelValues(name)
231-
}

0 commit comments

Comments
 (0)