Skip to content

Commit 5229bce

Browse files
authored
Merge pull request kubernetes#75279 from danielqsj/admission-metrics
remove the deprecated admission metrics
2 parents 8da0c4a + b31a340 commit 5229bce

File tree

1 file changed

+4
-40
lines changed
  • staging/src/k8s.io/apiserver/pkg/admission/metrics

1 file changed

+4
-40
lines changed

staging/src/k8s.io/apiserver/pkg/admission/metrics/metrics.go

Lines changed: 4 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -153,14 +153,12 @@ func (m *AdmissionMetrics) ObserveWebhook(elapsed time.Duration, rejected bool,
153153
}
154154

155155
type metricSet struct {
156-
latencies *prometheus.HistogramVec
157-
deprecatedLatencies *prometheus.HistogramVec
158-
latenciesSummary *prometheus.SummaryVec
159-
deprecatedLatenciesSummary *prometheus.SummaryVec
156+
latencies *prometheus.HistogramVec
157+
latenciesSummary *prometheus.SummaryVec
160158
}
161159

162160
func newMetricSet(name string, labels []string, helpTemplate string, hasSummary bool) *metricSet {
163-
var summary, deprecatedSummary *prometheus.SummaryVec
161+
var summary *prometheus.SummaryVec
164162
if hasSummary {
165163
summary = prometheus.NewSummaryVec(
166164
prometheus.SummaryOpts{
@@ -172,16 +170,6 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary
172170
},
173171
labels,
174172
)
175-
deprecatedSummary = prometheus.NewSummaryVec(
176-
prometheus.SummaryOpts{
177-
Namespace: namespace,
178-
Subsystem: subsystem,
179-
Name: fmt.Sprintf("%s_admission_latencies_milliseconds_summary", name),
180-
Help: fmt.Sprintf("(Deprecated) "+helpTemplate, "latency summary in milliseconds"),
181-
MaxAge: latencySummaryMaxAge,
182-
},
183-
labels,
184-
)
185173
}
186174

187175
return &metricSet{
@@ -195,56 +183,32 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary
195183
},
196184
labels,
197185
),
198-
deprecatedLatencies: prometheus.NewHistogramVec(
199-
prometheus.HistogramOpts{
200-
Namespace: namespace,
201-
Subsystem: subsystem,
202-
Name: fmt.Sprintf("%s_admission_latencies_milliseconds", name),
203-
Help: fmt.Sprintf("(Deprecated) "+helpTemplate, "latency histogram in milliseconds"),
204-
Buckets: latencyBuckets,
205-
},
206-
labels,
207-
),
208186

209-
latenciesSummary: summary,
210-
deprecatedLatenciesSummary: deprecatedSummary,
187+
latenciesSummary: summary,
211188
}
212189
}
213190

214191
// MustRegister registers all the prometheus metrics in the metricSet.
215192
func (m *metricSet) mustRegister() {
216193
prometheus.MustRegister(m.latencies)
217-
prometheus.MustRegister(m.deprecatedLatencies)
218194
if m.latenciesSummary != nil {
219195
prometheus.MustRegister(m.latenciesSummary)
220196
}
221-
if m.deprecatedLatenciesSummary != nil {
222-
prometheus.MustRegister(m.deprecatedLatenciesSummary)
223-
}
224197
}
225198

226199
// Reset resets all the prometheus metrics in the metricSet.
227200
func (m *metricSet) reset() {
228201
m.latencies.Reset()
229-
m.deprecatedLatencies.Reset()
230202
if m.latenciesSummary != nil {
231203
m.latenciesSummary.Reset()
232204
}
233-
if m.deprecatedLatenciesSummary != nil {
234-
m.deprecatedLatenciesSummary.Reset()
235-
}
236205
}
237206

238207
// Observe records an observed admission event to all metrics in the metricSet.
239208
func (m *metricSet) observe(elapsed time.Duration, labels ...string) {
240209
elapsedSeconds := elapsed.Seconds()
241-
elapsedMicroseconds := float64(elapsed / time.Microsecond)
242210
m.latencies.WithLabelValues(labels...).Observe(elapsedSeconds)
243-
m.deprecatedLatencies.WithLabelValues(labels...).Observe(elapsedMicroseconds)
244211
if m.latenciesSummary != nil {
245212
m.latenciesSummary.WithLabelValues(labels...).Observe(elapsedSeconds)
246213
}
247-
if m.deprecatedLatenciesSummary != nil {
248-
m.deprecatedLatenciesSummary.WithLabelValues(labels...).Observe(elapsedMicroseconds)
249-
}
250214
}

0 commit comments

Comments
 (0)