8
8
)
9
9
10
10
const (
11
- eventsMetricName = "operator_sdk_events "
12
- syncEventsMetricName = "operator_sdk_sync_events "
11
+ eventsMetricName = "operator_sdk_event_type "
12
+ syncEventsMetricName = "operator_sdk_reconcile_result "
13
13
// EventTypeLabel - metric label for event type
14
14
EventTypeLabel = "type"
15
15
// EventTypeAdd - addition event label
@@ -32,45 +32,43 @@ var (
32
32
33
33
// Collector - metric collector for all the metrics the sdk will watch
34
34
type Collector struct {
35
- Events * prom.CounterVec
36
- SyncEvents * prom.CounterVec
35
+ EventType * prom.CounterVec
36
+ ReconcileResult * prom.CounterVec
37
37
}
38
38
39
39
// New - create a new Collector
40
40
func New () * Collector {
41
41
return & Collector {
42
- Events : prom .NewCounterVec (prom.CounterOpts {
42
+ EventType : prom .NewCounterVec (prom.CounterOpts {
43
43
Name : eventsMetricName ,
44
- Help : "Events that the sdk has recieved, segmented by type(add or delete or update)" ,
44
+ Help : "events that the sdk has recieved, segmented by type(add or delete or update)" ,
45
45
}, []string {EventTypeLabel }),
46
- SyncEvents : prom .NewCounterVec (prom.CounterOpts {
46
+ ReconcileResult : prom .NewCounterVec (prom.CounterOpts {
47
47
Name : syncEventsMetricName ,
48
- Help : "events that the sdk has processed segmented by result(success or failure) includes reconcilation events. " ,
48
+ Help : "reconcilation events that the sdk has processed segmented by result(success or failure)" ,
49
49
}, []string {SyncResultLabel }),
50
50
}
51
51
}
52
52
53
- // RegisterCollector - add collector safetly to prometheus
53
+ // RegisterCollector - add collector safely to prometheus
54
54
func RegisterCollector (c * Collector ) {
55
- defer func () {
56
- if r := recover (); r != nil {
57
- logrus .Errorf ("unable to add metrics to prometheus: %v" , r )
58
- }
59
- }()
60
55
once .Do (func () {
61
- prom .MustRegister (c )
56
+ err := prom .Register (c )
57
+ if err != nil {
58
+ logrus .Errorf ("unable to register collector with prometheus: %v" , err )
59
+ }
62
60
})
63
61
}
64
62
65
63
// Describe returns all the descriptions of the collector
66
64
func (s * Collector ) Describe (ch chan <- * prom.Desc ) {
67
- s .Events .Describe (ch )
68
- s .SyncEvents .Describe (ch )
65
+ s .EventType .Describe (ch )
66
+ s .ReconcileResult .Describe (ch )
69
67
70
68
}
71
69
72
- // Collect returns the current ssstate of the metrics
70
+ // Collect returns the current state of the metrics
73
71
func (s * Collector ) Collect (ch chan <- prom.Metric ) {
74
- s .Events .Collect (ch )
75
- s .SyncEvents .Collect (ch )
72
+ s .EventType .Collect (ch )
73
+ s .ReconcileResult .Collect (ch )
76
74
}
0 commit comments