@@ -29,13 +29,15 @@ const (
2929 help = " Pod phase (enum-style, one active per Pod)"
3030)
3131
32+ // Creating the custom collector
3233var PodPhase = gvs.NewGaugeVecSet (
3334 namespace, subsystem, name, help,
3435 []string {" namespace" }, // index
3536 []string {" pod" }, // group
3637 " phase" , // extra (the enum value)
3738)
3839
40+ // Register the collector once
3941func init () {
4042 prometheus.MustRegister (PodPhase)
4143}
@@ -168,20 +170,22 @@ import (
168170// We need this variable later to create the ConditionMetricsRecorder
169171var OperatorConditionsGauge *ocg.OperatorConditionsGauge
170172
173+ // Initialize the operator condition gauge once
171174func init () {
172175 OperatorConditionsGauge = ocg.NewOperatorConditionsGauge (" my-operator" )
173176 controllermetrics.Registry .MustRegister (OperatorConditionsGauge)
174177}
175178
176179// Embed in existing metrics recorder
177180type MyControllerRecorder struct {
178- ocg.ConditionMetricRecorder
181+ ocg.ConditionMetricRecorder
179182}
180183```
181184
182185When constructing your reconciler, initialize the condition metrics recorder with the
183186operator conditions gauge and a unique name for each controller.
184187
188+ _ cmd/main.go_
185189``` go
186190package main
187191
0 commit comments