mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-24 20:24:09 +00:00
fix: async metric recording
This commit is contained in:
parent
7ef3cf5d07
commit
2a51bd81fa
@ -510,7 +510,7 @@ func (p *PriorityQueue) isPodWorthRequeuing(logger klog.Logger, pInfo *framework
|
|||||||
}
|
}
|
||||||
hint = framework.Queue
|
hint = framework.Queue
|
||||||
}
|
}
|
||||||
metrics.QueueingHintExecutionDuration.WithLabelValues(hintfn.PluginName, event.Label, queueingHintToLabel(hint, err)).Observe(metrics.SinceInSeconds(start))
|
p.metricsRecorder.ObserveQueueingHintDurationAsync(hintfn.PluginName, event.Label, queueingHintToLabel(hint, err), metrics.SinceInSeconds(start))
|
||||||
|
|
||||||
if hint == framework.QueueSkip {
|
if hint == framework.QueueSkip {
|
||||||
continue
|
continue
|
||||||
|
@ -119,9 +119,19 @@ func NewMetricsAsyncRecorder(bufferSize int, interval time.Duration, stopCh <-ch
|
|||||||
// ObservePluginDurationAsync observes the plugin_execution_duration_seconds metric.
|
// ObservePluginDurationAsync observes the plugin_execution_duration_seconds metric.
|
||||||
// The metric will be flushed to Prometheus asynchronously.
|
// The metric will be flushed to Prometheus asynchronously.
|
||||||
func (r *MetricAsyncRecorder) ObservePluginDurationAsync(extensionPoint, pluginName, status string, value float64) {
|
func (r *MetricAsyncRecorder) ObservePluginDurationAsync(extensionPoint, pluginName, status string, value float64) {
|
||||||
|
r.observeMetricAsync(PluginExecutionDuration, value, pluginName, extensionPoint, status)
|
||||||
|
}
|
||||||
|
|
||||||
|
// ObserveQueueingHintDurationAsync observes the queueing_hint_execution_duration_seconds metric.
|
||||||
|
// The metric will be flushed to Prometheus asynchronously.
|
||||||
|
func (r *MetricAsyncRecorder) ObserveQueueingHintDurationAsync(pluginName, event, hint string, value float64) {
|
||||||
|
r.observeMetricAsync(queueingHintExecutionDuration, value, pluginName, event, hint)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (r *MetricAsyncRecorder) observeMetricAsync(m *metrics.HistogramVec, value float64, labelsValues ...string) {
|
||||||
newMetric := &metric{
|
newMetric := &metric{
|
||||||
metric: PluginExecutionDuration,
|
metric: m,
|
||||||
labelValues: []string{pluginName, extensionPoint, status},
|
labelValues: labelsValues,
|
||||||
value: value,
|
value: value,
|
||||||
}
|
}
|
||||||
select {
|
select {
|
||||||
|
@ -207,11 +207,11 @@ var (
|
|||||||
[]string{"plugin", "extension_point", "status"})
|
[]string{"plugin", "extension_point", "status"})
|
||||||
|
|
||||||
// This is only available when the QHint feature gate is enabled.
|
// This is only available when the QHint feature gate is enabled.
|
||||||
QueueingHintExecutionDuration = metrics.NewHistogramVec(
|
queueingHintExecutionDuration = metrics.NewHistogramVec(
|
||||||
&metrics.HistogramOpts{
|
&metrics.HistogramOpts{
|
||||||
Subsystem: SchedulerSubsystem,
|
Subsystem: SchedulerSubsystem,
|
||||||
Name: "queueing_hint_execution_duration_seconds",
|
Name: "queueing_hint_execution_duration_seconds",
|
||||||
Help: "Duration for running a queueing hint from a plugin.",
|
Help: "Duration for running a queueing hint function of a plugin.",
|
||||||
// Start with 0.01ms with the last bucket being [~22ms, Inf). We use a small factor (1.5)
|
// Start with 0.01ms with the last bucket being [~22ms, Inf). We use a small factor (1.5)
|
||||||
// so that we have better granularity since plugin latency is very sensitive.
|
// so that we have better granularity since plugin latency is very sensitive.
|
||||||
Buckets: metrics.ExponentialBuckets(0.00001, 1.5, 20),
|
Buckets: metrics.ExponentialBuckets(0.00001, 1.5, 20),
|
||||||
@ -291,7 +291,7 @@ func Register() {
|
|||||||
registerMetrics.Do(func() {
|
registerMetrics.Do(func() {
|
||||||
RegisterMetrics(metricsList...)
|
RegisterMetrics(metricsList...)
|
||||||
if utilfeature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints) {
|
if utilfeature.DefaultFeatureGate.Enabled(features.SchedulerQueueingHints) {
|
||||||
RegisterMetrics(QueueingHintExecutionDuration)
|
RegisterMetrics(queueingHintExecutionDuration)
|
||||||
}
|
}
|
||||||
volumebindingmetrics.RegisterVolumeSchedulingMetrics()
|
volumebindingmetrics.RegisterVolumeSchedulingMetrics()
|
||||||
})
|
})
|
||||||
|
Loading…
Reference in New Issue
Block a user