Skip to content

Commit b0f52c2

Browse files
committed
add state to update run metrics
Signed-off-by: Britania Rodriguez Reyes <[email protected]>
1 parent 22f8aa5 commit b0f52c2

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

pkg/controllers/updaterun/controller.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -489,25 +489,26 @@ func handleApprovalRequestDelete(obj client.Object, q workqueue.TypedRateLimitin
489489
func emitUpdateRunStatusMetric(updateRun placementv1beta1.UpdateRunObj) {
490490
generation := updateRun.GetGeneration()
491491
genStr := strconv.FormatInt(generation, 10)
492+
state := string(updateRun.GetUpdateRunSpec().State)
492493

493494
updateRunStatus := updateRun.GetUpdateRunStatus()
494495
succeedCond := meta.FindStatusCondition(updateRunStatus.Conditions, string(placementv1beta1.StagedUpdateRunConditionSucceeded))
495496
if succeedCond != nil && succeedCond.ObservedGeneration == generation {
496-
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), genStr,
497+
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), state, genStr,
497498
string(placementv1beta1.StagedUpdateRunConditionSucceeded), string(succeedCond.Status), succeedCond.Reason).SetToCurrentTime()
498499
return
499500
}
500501

501502
progressingCond := meta.FindStatusCondition(updateRunStatus.Conditions, string(placementv1beta1.StagedUpdateRunConditionProgressing))
502503
if progressingCond != nil && progressingCond.ObservedGeneration == generation {
503-
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), genStr,
504+
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), state, genStr,
504505
string(placementv1beta1.StagedUpdateRunConditionProgressing), string(progressingCond.Status), progressingCond.Reason).SetToCurrentTime()
505506
return
506507
}
507508

508509
initializedCond := meta.FindStatusCondition(updateRunStatus.Conditions, string(placementv1beta1.StagedUpdateRunConditionInitialized))
509510
if initializedCond != nil && initializedCond.ObservedGeneration == generation {
510-
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), genStr,
511+
hubmetrics.FleetUpdateRunStatusLastTimestampSeconds.WithLabelValues(updateRun.GetNamespace(), updateRun.GetName(), state, genStr,
511512
string(placementv1beta1.StagedUpdateRunConditionInitialized), string(initializedCond.Status), initializedCond.Reason).SetToCurrentTime()
512513
return
513514
}

pkg/controllers/updaterun/controller_integration_test.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,7 @@ func generateMetricsLabels(
266266
return []*prometheusclientmodel.LabelPair{
267267
{Name: ptr.To("namespace"), Value: &updateRun.Namespace},
268268
{Name: ptr.To("name"), Value: &updateRun.Name},
269+
{Name: ptr.To("state"), Value: ptr.To(string(updateRun.Spec.State))},
269270
{Name: ptr.To("generation"), Value: ptr.To(strconv.FormatInt(updateRun.Generation, 10))},
270271
{Name: ptr.To("condition"), Value: ptr.To(condition)},
271272
{Name: ptr.To("status"), Value: ptr.To(status)},

pkg/metrics/hub/metrics.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ var (
4141
FleetUpdateRunStatusLastTimestampSeconds = prometheus.NewGaugeVec(prometheus.GaugeOpts{
4242
Name: "fleet_workload_update_run_status_last_timestamp_seconds",
4343
Help: "Last update timestamp of update run status in seconds",
44-
}, []string{"namespace", "name", "generation", "condition", "status", "reason"})
44+
}, []string{"namespace", "name", "state", "generation", "condition", "status", "reason"})
4545
)
4646

4747
// The scheduler related metrics.

0 commit comments

Comments
 (0)