Skip to content

Commit c036a6f

Browse files
authored
fix: update CRP metrics to add reason as label (#93)
1 parent aece481 commit c036a6f

File tree

3 files changed

+279
-36
lines changed

3 files changed

+279
-36
lines changed

pkg/controllers/clusterresourceplacement/controller.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1168,12 +1168,14 @@ func isCRPScheduled(crp *fleetv1beta1.ClusterResourcePlacement) bool {
11681168
func emitPlacementStatusMetric(crp *fleetv1beta1.ClusterResourcePlacement) {
11691169
// Check CRP Scheduled condition.
11701170
status := "nil"
1171+
reason := "nil"
11711172
cond := crp.GetCondition(string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType))
11721173
if !condition.IsConditionStatusTrue(cond, crp.Generation) {
11731174
if cond != nil && cond.ObservedGeneration == crp.Generation {
11741175
status = string(cond.Status)
1176+
reason = cond.Reason
11751177
}
1176-
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType), status).SetToCurrentTime()
1178+
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), string(fleetv1beta1.ClusterResourcePlacementScheduledConditionType), status, reason).SetToCurrentTime()
11771179
return
11781180
}
11791181

@@ -1184,13 +1186,14 @@ func emitPlacementStatusMetric(crp *fleetv1beta1.ClusterResourcePlacement) {
11841186
if !condition.IsConditionStatusTrue(cond, crp.Generation) {
11851187
if cond != nil && cond.ObservedGeneration == crp.Generation {
11861188
status = string(cond.Status)
1189+
reason = cond.Reason
11871190
}
1188-
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), string(condType.ClusterResourcePlacementConditionType()), status).SetToCurrentTime()
1191+
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), string(condType.ClusterResourcePlacementConditionType()), status, reason).SetToCurrentTime()
11891192
return
11901193
}
11911194
}
11921195

11931196
// Emit the "Completed" condition metric to indicate that the CRP has completed.
11941197
// This condition is used solely for metric reporting purposes.
1195-
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), "Completed", string(metav1.ConditionTrue)).SetToCurrentTime()
1198+
metrics.FleetPlacementStatusLastTimeStampSeconds.WithLabelValues(crp.Name, strconv.FormatInt(crp.Generation, 10), "Completed", string(metav1.ConditionTrue), "Completed").SetToCurrentTime()
11961199
}

0 commit comments

Comments
 (0)