@@ -34,51 +34,56 @@ func NewControllerMetricsCollector(crdsEnabled bool, constLabels map[string]stri
34
34
labelNamesController ,
35
35
)
36
36
37
- if ! crdsEnabled {
38
- return & ControllerMetricsCollector {ingressesTotal : ingResTotal }
37
+ var vsResTotal , vsrResTotal prometheus.Gauge
38
+ var tsResTotal * prometheus.GaugeVec
39
+
40
+ if crdsEnabled {
41
+ vsResTotal = prometheus .NewGauge (
42
+ prometheus.GaugeOpts {
43
+ Name : "virtualserver_resources_total" ,
44
+ Namespace : metricsNamespace ,
45
+ Help : "Number of handled VirtualServer resources" ,
46
+ ConstLabels : constLabels ,
47
+ },
48
+ )
49
+
50
+ vsrResTotal = prometheus .NewGauge (
51
+ prometheus.GaugeOpts {
52
+ Name : "virtualserverroute_resources_total" ,
53
+ Namespace : metricsNamespace ,
54
+ Help : "Number of handled VirtualServerRoute resources" ,
55
+ ConstLabels : constLabels ,
56
+ },
57
+ )
58
+
59
+ tsResTotal = prometheus .NewGaugeVec (
60
+ prometheus.GaugeOpts {
61
+ Name : "transportserver_resources_total" ,
62
+ Namespace : metricsNamespace ,
63
+ Help : "Number of handled TransportServer resources" ,
64
+ ConstLabels : constLabels ,
65
+ },
66
+ labelNamesController ,
67
+ )
39
68
}
40
69
41
- vsResTotal := prometheus .NewGauge (
42
- prometheus.GaugeOpts {
43
- Name : "virtualserver_resources_total" ,
44
- Namespace : metricsNamespace ,
45
- Help : "Number of handled VirtualServer resources" ,
46
- ConstLabels : constLabels ,
47
- },
48
- )
49
-
50
- vsrResTotal := prometheus .NewGauge (
51
- prometheus.GaugeOpts {
52
- Name : "virtualserverroute_resources_total" ,
53
- Namespace : metricsNamespace ,
54
- Help : "Number of handled VirtualServerRoute resources" ,
55
- ConstLabels : constLabels ,
56
- },
57
- )
58
-
59
- tsResTotal := prometheus .NewGaugeVec (
60
- prometheus.GaugeOpts {
61
- Name : "transportserver_resources_total" ,
62
- Namespace : metricsNamespace ,
63
- Help : "Number of handled TransportServer resources" ,
64
- ConstLabels : constLabels ,
65
- },
66
- labelNamesController ,
67
- )
68
-
69
70
c := & ControllerMetricsCollector {
70
- crdsEnabled : true ,
71
+ crdsEnabled : crdsEnabled ,
71
72
ingressesTotal : ingResTotal ,
72
73
virtualServersTotal : vsResTotal ,
73
74
virtualServerRoutesTotal : vsrResTotal ,
74
75
transportServersTotal : tsResTotal ,
75
76
}
76
77
77
- // if we don't set to 0 metrics with types, the metrics will not be created initially
78
+ // if we don't set to 0 metrics with the label type, the metrics will not be created initially
79
+
78
80
c .SetIngresses ("regular" , 0 )
79
81
c .SetIngresses ("master" , 0 )
80
82
c .SetIngresses ("minion" , 0 )
81
- c .SetTransportServers (0 , 0 , 0 )
83
+
84
+ if crdsEnabled {
85
+ c .SetTransportServers (0 , 0 , 0 )
86
+ }
82
87
83
88
return c
84
89
}
0 commit comments