remove the deprecated admission metrics
Kubernetes-commit: b31a3403c4b60d421900d9ddef3a27d23ea9c4c6
This commit is contained in:
		
							parent
							
								
									d5ae2df97a
								
							
						
					
					
						commit
						1de9bb3580
					
				|  | @ -154,13 +154,11 @@ func (m *AdmissionMetrics) ObserveWebhook(elapsed time.Duration, rejected bool, | |||
| 
 | ||||
| type metricSet struct { | ||||
| 	latencies        *prometheus.HistogramVec | ||||
| 	deprecatedLatencies        *prometheus.HistogramVec | ||||
| 	latenciesSummary *prometheus.SummaryVec | ||||
| 	deprecatedLatenciesSummary *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, | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| // 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) | ||||
| 	} | ||||
| } | ||||
|  |  | |||
		Loading…
	
		Reference in New Issue