Skip to content

Commit

Permalink
include metric labels in log message
Browse files Browse the repository at this point in the history
* Fix error format specifier in log message
  • Loading branch information
cjerad committed Sep 16, 2021
1 parent 5123d91 commit a9d69d2
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 deletions pkg/controllers/allocation/scheduling/scheduler.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit a9d69d2

Please sign in to comment.