mirror of
https://github.com/kubernetes-sigs/prometheus-adapter.git
synced 2026-04-08 06:33:56 +00:00
vendored changes
This commit is contained in:
parent
d091fff18b
commit
128f9a29f5
522 changed files with 29974 additions and 25705 deletions
48
vendor/k8s.io/apiserver/pkg/admission/metrics/metrics.go
generated
vendored
48
vendor/k8s.io/apiserver/pkg/admission/metrics/metrics.go
generated
vendored
|
|
@ -32,8 +32,8 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
// Use buckets ranging from 25 ms to ~2.5 seconds.
|
||||
latencyBuckets = prometheus.ExponentialBuckets(25000, 2.5, 5)
|
||||
// Use buckets ranging from 5 ms to 2.5 seconds (admission webhooks timeout at 30 seconds by default).
|
||||
latencyBuckets = []float64{0.005, 0.025, 0.1, 0.5, 2.5}
|
||||
latencySummaryMaxAge = 5 * time.Hour
|
||||
|
||||
// Metrics provides access to all admission metrics.
|
||||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue