From a9d69d26b6845fd6fb0b2e1f683ac8f83223d757 Mon Sep 17 00:00:00 2001 From: Jerad C Date: Thu, 16 Sep 2021 15:20:27 -0500 Subject: [PATCH] include metric labels in log message * Fix error format specifier in log message --- .../allocation/scheduling/scheduler.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/pkg/controllers/allocation/scheduling/scheduler.go b/pkg/controllers/allocation/scheduling/scheduler.go index 4344e8ce7ec6..311cf79d55cb 100644 --- a/pkg/controllers/allocation/scheduling/scheduler.go +++ b/pkg/controllers/allocation/scheduling/scheduler.go @@ -81,20 +81,17 @@ func (s *Scheduler) Solve(ctx context.Context, provisioner *v1alpha3.Provisioner result = "error" } - provisionerName := provisioner.ObjectMeta.Name - observer, promErr := scheduleTimeHistogramVec.GetMetricWith(prometheus.Labels{ - metrics.ProvisionerLabel: provisionerName, + labels := prometheus.Labels{ + metrics.ProvisionerLabel: provisioner.ObjectMeta.Name, metrics.ResultLabel: result, - }) + } + observer, promErr := scheduleTimeHistogramVec.GetMetricWith(labels) if promErr != nil { logging.FromContext(ctx).Warnf( - "Failed to record scheduling duration metric [%s=%s, %s=%s, duration=%f]: error=%w", - metrics.ProvisionerLabel, - provisionerName, - metrics.ResultLabel, - result, + "Failed to record scheduling duration metric [labels=%s, duration=%f]: error=%s", + labels, durationSeconds, - promErr, + promErr.Error(), ) } else { observer.Observe(durationSeconds)