@@ -19,6 +19,7 @@ import (
1919// Describe is method required to implement the prometheus.Collect interface.
2020func (c * controller ) Describe (ch chan <- * prometheus.Desc ) {
2121 ch <- metrics .MachineCountDesc
22+ ch <- metrics .MachineCSPhase
2223}
2324
2425// Collect is method required to implement the prometheus.Collect interface.
@@ -41,7 +42,7 @@ func (c *controller) CollectMachineMetrics(ch chan<- prometheus.Metric) {
4142 mSpec := machine .Spec
4243 updateMachineInfoMetric (mMeta , mSpec )
4344 updateMachineStatusConditionMetric (machine , mMeta )
44- updateMachineCSPhaseMetric (machine , mMeta )
45+ updateMachineCSPhaseMetric (machine , mMeta , ch )
4546 }
4647
4748 updateMachineCountMetric (ch , machineList )
@@ -70,7 +71,7 @@ func updateMachineCountMetric(ch chan<- prometheus.Metric, machineList []*v1alph
7071 ch <- metric
7172}
7273
73- func updateMachineCSPhaseMetric (machine * v1alpha1.Machine , mMeta metav1.ObjectMeta ) {
74+ func updateMachineCSPhaseMetric (machine * v1alpha1.Machine , mMeta metav1.ObjectMeta , ch chan <- prometheus. Metric ) {
7475 var phase float64
7576 switch machine .Status .CurrentStatus .Phase {
7677 case v1alpha1 .MachineTerminating :
@@ -86,10 +87,14 @@ func updateMachineCSPhaseMetric(machine *v1alpha1.Machine, mMeta metav1.ObjectMe
8687 case v1alpha1 .MachineRunning :
8788 phase = 1
8889 }
89- metrics .MachineCSPhase .With (prometheus.Labels {
90- "name" : mMeta .Name ,
91- "namespace" : mMeta .Namespace ,
92- }).Set (phase )
90+
91+ ch <- prometheus .MustNewConstMetric (
92+ metrics .MachineCSPhase ,
93+ prometheus .GaugeValue ,
94+ phase ,
95+ mMeta .Name ,
96+ mMeta .Namespace ,
97+ )
9398}
9499
95100func updateMachineStatusConditionMetric (machine * v1alpha1.Machine , mMeta metav1.ObjectMeta ) {
0 commit comments