From de1385fe1bd74a3f5cd2be41f5881be4cdc0c287 Mon Sep 17 00:00:00 2001 From: Roman Baron Date: Wed, 11 Mar 2026 22:45:15 +0200 Subject: [PATCH] scheduler: Added ObserveFrameworkDurationAsync to metrics recorder --- pkg/scheduler/framework/runtime/framework.go | 12 +++++++++++- pkg/scheduler/metrics/metric_recorder.go | 6 ++++++ pkg/scheduler/metrics/metrics.go | 1 + 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/pkg/scheduler/framework/runtime/framework.go b/pkg/scheduler/framework/runtime/framework.go index 5cf59aec3e0..e3833ee3ca8 100644 --- a/pkg/scheduler/framework/runtime/framework.go +++ b/pkg/scheduler/framework/runtime/framework.go @@ -850,17 +850,27 @@ func (f *frameworkImpl) computeBatchablePlugins() { // there is no way to compare this pod against others, and will turn off a number of optimizations // for this pod. func (f *frameworkImpl) SignPod(ctx context.Context, pod *v1.Pod) fwk.PodSignature { + logger := klog.FromContext(ctx) + var status *fwk.Status + + startTime := time.Now() + defer func() { + f.metricsRecorder.ObserveFrameworkDurationAsync(metrics.Sign, status.Code().String(), f.profileName, metrics.SinceInSeconds(startTime)) + }() + if !f.enableSignatures { return nil } - logger := klog.FromContext(ctx) sig := map[string]any{ fwk.SchedulerNameSignerName: pod.Spec.SchedulerName, } for _, plugin := range f.batchablePlugins { + startTime := time.Now() fragments, status := plugin.SignPod(ctx, pod) + f.metricsRecorder.ObservePluginDurationAsync(metrics.Sign, plugin.Name(), status.Code().String(), metrics.SinceInSeconds(startTime)) + if !status.IsSuccess() { if status.Code() == fwk.Error { logger.Error(status.AsError(), "SignPod failed for plugin", "plugin", plugin.Name()) diff --git a/pkg/scheduler/metrics/metric_recorder.go b/pkg/scheduler/metrics/metric_recorder.go index f59ea1e96f7..3610f91fa79 100644 --- a/pkg/scheduler/metrics/metric_recorder.go +++ b/pkg/scheduler/metrics/metric_recorder.go @@ -138,6 +138,12 @@ func NewMetricsAsyncRecorder(bufferSize int, interval time.Duration, stopCh <-ch return recorder } +// ObserveFrameworkDurationAsync observes the framework_extension_point_duration_seconds metric. +// The metric will be flushed to Prometheus asynchronously. +func (r *MetricAsyncRecorder) ObserveFrameworkDurationAsync(extensionPoint, status, profileName string, value float64) { + r.observeMetricAsync(FrameworkExtensionPointDuration, value, extensionPoint, status, profileName) +} + // ObservePluginDurationAsync observes the plugin_execution_duration_seconds metric. // The metric will be flushed to Prometheus asynchronously. func (r *MetricAsyncRecorder) ObservePluginDurationAsync(extensionPoint, pluginName, status string, value float64) { diff --git a/pkg/scheduler/metrics/metrics.go b/pkg/scheduler/metrics/metrics.go index 0fb5e806f4b..19f16013472 100644 --- a/pkg/scheduler/metrics/metrics.go +++ b/pkg/scheduler/metrics/metrics.go @@ -62,6 +62,7 @@ var ExtensionPoints = []string{ Reserve, Unreserve, Permit, + Sign, } const (