mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-02 08:17:26 +00:00
remove the deprecated admission metrics
This commit is contained in:
parent
eb6a1b651c
commit
b31a3403c4
@ -154,13 +154,11 @@ func (m *AdmissionMetrics) ObserveWebhook(elapsed time.Duration, rejected bool,
|
|||||||
|
|
||||||
type metricSet struct {
|
type metricSet struct {
|
||||||
latencies *prometheus.HistogramVec
|
latencies *prometheus.HistogramVec
|
||||||
deprecatedLatencies *prometheus.HistogramVec
|
|
||||||
latenciesSummary *prometheus.SummaryVec
|
latenciesSummary *prometheus.SummaryVec
|
||||||
deprecatedLatenciesSummary *prometheus.SummaryVec
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func newMetricSet(name string, labels []string, helpTemplate string, hasSummary bool) *metricSet {
|
func newMetricSet(name string, labels []string, helpTemplate string, hasSummary bool) *metricSet {
|
||||||
var summary, deprecatedSummary *prometheus.SummaryVec
|
var summary *prometheus.SummaryVec
|
||||||
if hasSummary {
|
if hasSummary {
|
||||||
summary = prometheus.NewSummaryVec(
|
summary = prometheus.NewSummaryVec(
|
||||||
prometheus.SummaryOpts{
|
prometheus.SummaryOpts{
|
||||||
@ -172,16 +170,6 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary
|
|||||||
},
|
},
|
||||||
labels,
|
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{
|
return &metricSet{
|
||||||
@ -195,56 +183,32 @@ func newMetricSet(name string, labels []string, helpTemplate string, hasSummary
|
|||||||
},
|
},
|
||||||
labels,
|
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,
|
latenciesSummary: summary,
|
||||||
deprecatedLatenciesSummary: deprecatedSummary,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// MustRegister registers all the prometheus metrics in the metricSet.
|
// MustRegister registers all the prometheus metrics in the metricSet.
|
||||||
func (m *metricSet) mustRegister() {
|
func (m *metricSet) mustRegister() {
|
||||||
prometheus.MustRegister(m.latencies)
|
prometheus.MustRegister(m.latencies)
|
||||||
prometheus.MustRegister(m.deprecatedLatencies)
|
|
||||||
if m.latenciesSummary != nil {
|
if m.latenciesSummary != nil {
|
||||||
prometheus.MustRegister(m.latenciesSummary)
|
prometheus.MustRegister(m.latenciesSummary)
|
||||||
}
|
}
|
||||||
if m.deprecatedLatenciesSummary != nil {
|
|
||||||
prometheus.MustRegister(m.deprecatedLatenciesSummary)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Reset resets all the prometheus metrics in the metricSet.
|
// Reset resets all the prometheus metrics in the metricSet.
|
||||||
func (m *metricSet) reset() {
|
func (m *metricSet) reset() {
|
||||||
m.latencies.Reset()
|
m.latencies.Reset()
|
||||||
m.deprecatedLatencies.Reset()
|
|
||||||
if m.latenciesSummary != nil {
|
if m.latenciesSummary != nil {
|
||||||
m.latenciesSummary.Reset()
|
m.latenciesSummary.Reset()
|
||||||
}
|
}
|
||||||
if m.deprecatedLatenciesSummary != nil {
|
|
||||||
m.deprecatedLatenciesSummary.Reset()
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Observe records an observed admission event to all metrics in the metricSet.
|
// Observe records an observed admission event to all metrics in the metricSet.
|
||||||
func (m *metricSet) observe(elapsed time.Duration, labels ...string) {
|
func (m *metricSet) observe(elapsed time.Duration, labels ...string) {
|
||||||
elapsedSeconds := elapsed.Seconds()
|
elapsedSeconds := elapsed.Seconds()
|
||||||
elapsedMicroseconds := float64(elapsed / time.Microsecond)
|
|
||||||
m.latencies.WithLabelValues(labels...).Observe(elapsedSeconds)
|
m.latencies.WithLabelValues(labels...).Observe(elapsedSeconds)
|
||||||
m.deprecatedLatencies.WithLabelValues(labels...).Observe(elapsedMicroseconds)
|
|
||||||
if m.latenciesSummary != nil {
|
if m.latenciesSummary != nil {
|
||||||
m.latenciesSummary.WithLabelValues(labels...).Observe(elapsedSeconds)
|
m.latenciesSummary.WithLabelValues(labels...).Observe(elapsedSeconds)
|
||||||
}
|
}
|
||||||
if m.deprecatedLatenciesSummary != nil {
|
|
||||||
m.deprecatedLatenciesSummary.WithLabelValues(labels...).Observe(elapsedMicroseconds)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user