mirror of
https://github.com/k3s-io/kubernetes.git
synced 2026-07-19 23:51:08 +00:00
scheduler: Added ObserveFrameworkDurationAsync to metrics recorder
This commit is contained in:
@@ -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())
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -62,6 +62,7 @@ var ExtensionPoints = []string{
|
||||
Reserve,
|
||||
Unreserve,
|
||||
Permit,
|
||||
Sign,
|
||||
}
|
||||
|
||||
const (
|
||||
|
||||
Reference in New Issue
Block a user