scheduler: Added ObserveFrameworkDurationAsync to metrics recorder

This commit is contained in:
Roman Baron
2026-03-11 22:45:15 +02:00
parent 7b00255135
commit de1385fe1b
3 changed files with 18 additions and 1 deletions

View File

@@ -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())

View File

@@ -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) {

View File

@@ -62,6 +62,7 @@ var ExtensionPoints = []string{
Reserve,
Unreserve,
Permit,
Sign,
}
const (