Skip to content

Commit 7fb51de

Browse files
authored
update doc strings (#3)
1 parent 40b1b38 commit 7fb51de

File tree

2 files changed

+13
-27
lines changed

2 files changed

+13
-27
lines changed

pkg/gauge_vec_set/gauge_vec_set.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ type GaugeVecSet struct {
6666
// Returns an *unregistered* collector; register it with a Prometheus registry yourself.
6767
// Example:
6868
//
69-
// col := NewGaugeVecSet(ns, sub, "condition", help, []string{"controller","name","namespace"}, []string{"condition"}, []string{"status","reason"})
69+
// col := NewGaugeVecSet(ns, sub, name, help, []string{"namespace"}, []string{"pod"}, []string{"phase"})
7070
// prometheus.MustRegister(col)
7171
func NewGaugeVecSet(
7272
namespace, subsystem, name, help string,
@@ -281,7 +281,7 @@ func (c *GaugeVecSet) cacheWithKeys(indexKey, groupKey, fullKey string) {
281281
}
282282

283283
// Set assigns the Gauge value for the series identified by (index, group)
284-
// This does not modify sibling series. Use SetExclusiveInGroup or SetActiveInGroup to enforce enum-like exclusivity.
284+
// This does not modify sibling series. Use SetGroup or SetActiveInGroup to enforce exclusivity on the group level.
285285
func (c *GaugeVecSet) Set(
286286
value float64,
287287
indexValues []string,

pkg/operator_condition_metrics/operator_condition_metrics.go

Lines changed: 11 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -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

9286
const (
@@ -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+
// }
117111
func 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)
160150
type 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")
189175
func (r *ConditionMetricRecorder) RecordConditionFor(
190176
kind string, object ObjectLike, conditionType, conditionStatus, conditionReason string,
191177
) {

0 commit comments

Comments
 (0)