@@ -81,12 +81,6 @@ Implementation
8181 groupLabels = [condition]
8282 extraLabels = [status, reason]
8383 Exclusivity is enforced with SetGroup(), which deletes sibling series.
84-
85- Notes
86- - KIND: In controller-runtime, obj.GetObjectKind().GroupVersionKind().Kind can be empty if
87- GVK wasn't populated. Ensure your scheme is registered and objects are decoded via the client;
88- otherwise, resolve Kind via the scheme (scheme.ObjectKinds(obj)).
89- - Cluster-scoped: namespace label is set to the empty string "".
9084*/
9185
9286const (
@@ -108,12 +102,12 @@ type OperatorConditionsGauge struct {
108102// NewOperatorConditionsGauge creates a new OperatorConditionsGauge for an operator.
109103// Initialize once (e.g., in your package init or setup)
110104//
111- // var OperatorConditionsGauge *OperatorConditionsGauge = nil
105+ // var OperatorConditionsGauge *OperatorConditionsGauge = nil
112106//
113- // func init() {
114- // OperatorConditionsGauge = NewOperatorConditionsGauge("my-operator")
115- // controllermetrics.Registry.MustRegister(OperatorConditionsGauge)
116- // }
107+ // func init() {
108+ // OperatorConditionsGauge = NewOperatorConditionsGauge("my-operator")
109+ // controllermetrics.Registry.MustRegister(OperatorConditionsGauge)
110+ // }
117111func NewOperatorConditionsGauge (metricNamespace string ) * OperatorConditionsGauge {
118112 return & OperatorConditionsGauge {
119113 metrics .NewGaugeVecSet (
@@ -136,27 +130,23 @@ type ObjectLike interface {
136130// ConditionMetricRecorder records metrics for Kubernetes style `metav1.Condition`
137131// objects on custom resources, using a Prometheus gauge.
138132//
139- // It is intended for use in controller implementations that expose CRD conditions
140- // (e.g., Ready, Reconciled, Synchronized).
141- //
142133// Usage:
143134//
144135// Embed in your custom recorder or reconciler
145136//
146137// type MyRecorder struct {
147- // metrics .ConditionMetricRecorder
138+ // gvs .ConditionMetricRecorder
148139// }
149140//
150141// r := MyControllerRecorder{
151- // ConditionMetricRecorder: metrics .ConditionMetricRecorder{
142+ // ConditionMetricRecorder: gvs .ConditionMetricRecorder{
152143// Controller: "my-controller",
153- // OperatorConditionsGauge: OperatorConditionsGauge,
144+ // OperatorConditionsGauge: my_metrics. OperatorConditionsGauge,
154145// },
155146// }
156147//
157- // r.RecordConditionFor(myObj, condition)
158- // r.SetStatusCondition(myObj, &myObj.Status.Conditions, condition) // wrapper for meta.SetStatusCondition
159- // r.RemoveConditionsFor(myObj)
148+ // r.RecordConditionFor(kind, obj, cond.Type, string(cond.Status), cond.Reason)
149+ // r.RemoveConditionsFor(kind, obj)
160150type ConditionMetricRecorder struct {
161151 // The name of the controller the condition metrics are for
162152 Controller string
@@ -181,11 +171,7 @@ type ConditionMetricRecorder struct {
181171//
182172// Example:
183173//
184- // r.RecordConditionFor(obj, metav1.Condition{
185- // Type: "Ready",
186- // Status: metav1.ConditionFalse,
187- // Reason: "KeyAuthorizationError",
188- // })
174+ // r.RecordConditionFor(kind, obj, "Ready", "True", "AppReady")
189175func (r * ConditionMetricRecorder ) RecordConditionFor (
190176 kind string , object ObjectLike , conditionType , conditionStatus , conditionReason string ,
191177) {
0 commit comments