From 1de9bb35804558329154bd70d3260d5682080a7b Mon Sep 17 00:00:00 2001 From: danielqsj Date: Tue, 12 Mar 2019 14:06:38 +0800 Subject: [PATCH] remove the deprecated admission metrics Kubernetes-commit: b31a3403c4b60d421900d9ddef3a27d23ea9c4c6 --- pkg/admission/metrics/metrics.go | 44 +++----------------------------- 1 file changed, 4 insertions(+), 40 deletions(-) diff --git a/pkg/admission/metrics/metrics.go b/pkg/admission/metrics/metrics.go index e445e2abd..04eb7b522 100644 --- a/pkg/admission/metrics/metrics.go +++ b/pkg/admission/metrics/metrics.go @@ -153,14 +153,12 @@ func (m *AdmissionMetrics) ObserveWebhook(elapsed time.Duration, rejected bool, } type metricSet struct { - latencies *prometheus.HistogramVec - deprecatedLatencies *prometheus.HistogramVec - latenciesSummary *prometheus.SummaryVec - deprecatedLatenciesSummary *prometheus.SummaryVec + latencies *prometheus.HistogramVec + latenciesSummary *prometheus.SummaryVec } func newMetricSet(name string, labels []string, helpTemplate string, hasSummary bool) *metricSet { - var summary, deprecatedSummary *prometheus.SummaryVec + var summary *prometheus.SummaryVec if hasSummary { summary = prometheus.NewSummaryVec( prometheus.SummaryOpts{ @@ -172,16 +170,6 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary }, labels, ) - deprecatedSummary = prometheus.NewSummaryVec( - prometheus.SummaryOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: fmt.Sprintf("%s_admission_latencies_milliseconds_summary", name), - Help: fmt.Sprintf("(Deprecated) "+helpTemplate, "latency summary in milliseconds"), - MaxAge: latencySummaryMaxAge, - }, - labels, - ) } return &metricSet{ @@ -195,56 +183,32 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary }, labels, ), - deprecatedLatencies: prometheus.NewHistogramVec( - prometheus.HistogramOpts{ - Namespace: namespace, - Subsystem: subsystem, - Name: fmt.Sprintf("%s_admission_latencies_milliseconds", name), - Help: fmt.Sprintf("(Deprecated) "+helpTemplate, "latency histogram in milliseconds"), - Buckets: latencyBuckets, - }, - labels, - ), - latenciesSummary: summary, - deprecatedLatenciesSummary: deprecatedSummary, + latenciesSummary: summary, } } // MustRegister registers all the prometheus metrics in the metricSet. func (m *metricSet) mustRegister() { prometheus.MustRegister(m.latencies) - prometheus.MustRegister(m.deprecatedLatencies) if m.latenciesSummary != nil { prometheus.MustRegister(m.latenciesSummary) } - if m.deprecatedLatenciesSummary != nil { - prometheus.MustRegister(m.deprecatedLatenciesSummary) - } } // Reset resets all the prometheus metrics in the metricSet. func (m *metricSet) reset() { m.latencies.Reset() - m.deprecatedLatencies.Reset() if m.latenciesSummary != nil { m.latenciesSummary.Reset() } - if m.deprecatedLatenciesSummary != nil { - m.deprecatedLatenciesSummary.Reset() - } } // Observe records an observed admission event to all metrics in the metricSet. func (m *metricSet) observe(elapsed time.Duration, labels ...string) { elapsedSeconds := elapsed.Seconds() - elapsedMicroseconds := float64(elapsed / time.Microsecond) m.latencies.WithLabelValues(labels...).Observe(elapsedSeconds) - m.deprecatedLatencies.WithLabelValues(labels...).Observe(elapsedMicroseconds) if m.latenciesSummary != nil { m.latenciesSummary.WithLabelValues(labels...).Observe(elapsedSeconds) } - if m.deprecatedLatenciesSummary != nil { - m.deprecatedLatenciesSummary.WithLabelValues(labels...).Observe(elapsedMicroseconds) - } }