Skip to content

Commit 4342ca7

Browse files
Migrate all NewFamilyGenerator to NewFamilyGeneratorWithStability
1 parent 5da24c2 commit 4342ca7

35 files changed

+249
-121
lines changed

internal/store/certificatesigningrequest.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,11 @@ var (
4242

4343
func csrMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
4444
return []generator.FamilyGenerator{
45-
*generator.NewFamilyGenerator(
45+
*generator.NewFamilyGeneratorWithStability(
4646
descCSRAnnotationsName,
4747
descCSRAnnotationsHelp,
4848
metric.Gauge,
49+
basemetrics.ALPHA,
4950
"",
5051
wrapCSRFunc(func(j *certv1.CertificateSigningRequest) *metric.Family {
5152
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", j.Annotations, allowAnnotationsList)

internal/store/clusterrole.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"k8s.io/apimachinery/pkg/watch"
2626
clientset "k8s.io/client-go/kubernetes"
2727
"k8s.io/client-go/tools/cache"
28+
basemetrics "k8s.io/component-base/metrics"
2829

2930
"k8s.io/kube-state-metrics/v2/pkg/metric"
3031
generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator"
@@ -40,10 +41,11 @@ var (
4041

4142
func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
4243
return []generator.FamilyGenerator{
43-
*generator.NewFamilyGenerator(
44+
*generator.NewFamilyGeneratorWithStability(
4445
descClusterRoleAnnotationsName,
4546
descClusterRoleAnnotationsHelp,
4647
metric.Gauge,
48+
basemetrics.ALPHA,
4749
"",
4850
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
4951
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", r.Annotations, allowAnnotationsList)
@@ -58,10 +60,11 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
5860
}
5961
}),
6062
),
61-
*generator.NewFamilyGenerator(
63+
*generator.NewFamilyGeneratorWithStability(
6264
descClusterRoleLabelsName,
6365
descClusterRoleLabelsHelp,
6466
metric.Gauge,
67+
basemetrics.ALPHA,
6568
"",
6669
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
6770
labelKeys, labelValues := createPrometheusLabelKeysValues("label", r.Labels, allowLabelsList)
@@ -76,10 +79,11 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
7679
}
7780
}),
7881
),
79-
*generator.NewFamilyGenerator(
82+
*generator.NewFamilyGeneratorWithStability(
8083
"kube_clusterrole_info",
8184
"Information about cluster role.",
8285
metric.Gauge,
86+
basemetrics.ALPHA,
8387
"",
8488
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
8589
return &metric.Family{
@@ -91,10 +95,11 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
9195
}
9296
}),
9397
),
94-
*generator.NewFamilyGenerator(
98+
*generator.NewFamilyGeneratorWithStability(
9599
"kube_clusterrole_created",
96100
"Unix creation timestamp",
97101
metric.Gauge,
102+
basemetrics.ALPHA,
98103
"",
99104
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
100105
ms := []*metric.Metric{}
@@ -112,10 +117,11 @@ func clusterRoleMetricFamilies(allowAnnotationsList, allowLabelsList []string) [
112117
}
113118
}),
114119
),
115-
*generator.NewFamilyGenerator(
120+
*generator.NewFamilyGeneratorWithStability(
116121
"kube_clusterrole_metadata_resource_version",
117122
"Resource version representing a specific version of the cluster role.",
118123
metric.Gauge,
124+
basemetrics.ALPHA,
119125
"",
120126
wrapClusterRoleFunc(func(r *rbacv1.ClusterRole) *metric.Family {
121127
return &metric.Family{

internal/store/clusterrolebinding.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import (
2525
"k8s.io/apimachinery/pkg/watch"
2626
clientset "k8s.io/client-go/kubernetes"
2727
"k8s.io/client-go/tools/cache"
28+
basemetrics "k8s.io/component-base/metrics"
2829

2930
"k8s.io/kube-state-metrics/v2/pkg/metric"
3031
generator "k8s.io/kube-state-metrics/v2/pkg/metric_generator"
@@ -40,10 +41,11 @@ var (
4041

4142
func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
4243
return []generator.FamilyGenerator{
43-
*generator.NewFamilyGenerator(
44+
*generator.NewFamilyGeneratorWithStability(
4445
descClusterRoleBindingAnnotationsName,
4546
descClusterRoleBindingAnnotationsHelp,
4647
metric.Gauge,
48+
basemetrics.ALPHA,
4749
"",
4850
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
4951
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", r.Annotations, allowAnnotationsList)
@@ -58,10 +60,11 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
5860
}
5961
}),
6062
),
61-
*generator.NewFamilyGenerator(
63+
*generator.NewFamilyGeneratorWithStability(
6264
descClusterRoleBindingLabelsName,
6365
descClusterRoleBindingLabelsHelp,
6466
metric.Gauge,
67+
basemetrics.ALPHA,
6568
"",
6669
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
6770
labelKeys, labelValues := createPrometheusLabelKeysValues("label", r.Labels, allowLabelsList)
@@ -76,10 +79,11 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
7679
}
7780
}),
7881
),
79-
*generator.NewFamilyGenerator(
82+
*generator.NewFamilyGeneratorWithStability(
8083
"kube_clusterrolebinding_info",
8184
"Information about clusterrolebinding.",
8285
metric.Gauge,
86+
basemetrics.ALPHA,
8387
"",
8488
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
8589
labelKeys := []string{"roleref_kind", "roleref_name"}
@@ -93,10 +97,11 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
9397
}
9498
}),
9599
),
96-
*generator.NewFamilyGenerator(
100+
*generator.NewFamilyGeneratorWithStability(
97101
"kube_clusterrolebinding_created",
98102
"Unix creation timestamp",
99103
metric.Gauge,
104+
basemetrics.ALPHA,
100105
"",
101106
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
102107
ms := []*metric.Metric{}
@@ -114,10 +119,11 @@ func clusterRoleBindingMetricFamilies(allowAnnotationsList, allowLabelsList []st
114119
}
115120
}),
116121
),
117-
*generator.NewFamilyGenerator(
122+
*generator.NewFamilyGeneratorWithStability(
118123
"kube_clusterrolebinding_metadata_resource_version",
119124
"Resource version representing a specific version of the clusterrolebinding.",
120125
metric.Gauge,
126+
basemetrics.ALPHA,
121127
"",
122128
wrapClusterRoleBindingFunc(func(r *rbacv1.ClusterRoleBinding) *metric.Family {
123129
return &metric.Family{

internal/store/configmap.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,11 @@ var (
3737

3838
func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
3939
return []generator.FamilyGenerator{
40-
*generator.NewFamilyGenerator(
40+
*generator.NewFamilyGeneratorWithStability(
4141
"kube_configmap_annotations",
4242
"Kubernetes annotations converted to Prometheus labels.",
4343
metric.Gauge,
44+
basemetrics.ALPHA,
4445
"",
4546
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
4647
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", c.Annotations, allowAnnotationsList)
@@ -112,10 +113,11 @@ func configMapMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
112113
}
113114
}),
114115
),
115-
*generator.NewFamilyGenerator(
116+
*generator.NewFamilyGeneratorWithStability(
116117
"kube_configmap_metadata_resource_version",
117118
"Resource version representing a specific version of the configmap.",
118119
metric.Gauge,
120+
basemetrics.ALPHA,
119121
"",
120122
wrapConfigMapFunc(func(c *v1.ConfigMap) *metric.Family {
121123
return &metric.Family{

internal/store/cronjob.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,11 @@ var (
4545

4646
func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
4747
return []generator.FamilyGenerator{
48-
*generator.NewFamilyGenerator(
48+
*generator.NewFamilyGeneratorWithStability(
4949
descCronJobAnnotationsName,
5050
descCronJobAnnotationsHelp,
5151
metric.Gauge,
52+
basemetrics.ALPHA,
5253
"",
5354
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
5455
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", j.Annotations, allowAnnotationsList)
@@ -161,10 +162,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
161162
}
162163
}),
163164
),
164-
*generator.NewFamilyGenerator(
165+
*generator.NewFamilyGeneratorWithStability(
165166
"kube_cronjob_status_last_successful_time",
166167
"LastSuccessfulTime keeps information of when was the last time the job was completed successfully.",
167168
metric.Gauge,
169+
basemetrics.ALPHA,
168170
"",
169171
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
170172
ms := []*metric.Metric{}
@@ -265,10 +267,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
265267
}
266268
}),
267269
),
268-
*generator.NewFamilyGenerator(
270+
*generator.NewFamilyGeneratorWithStability(
269271
"kube_cronjob_spec_successful_job_history_limit",
270272
"Successful job history limit tells the controller how many completed jobs should be preserved.",
271273
metric.Gauge,
274+
basemetrics.ALPHA,
272275
"",
273276
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
274277
ms := []*metric.Metric{}
@@ -286,10 +289,11 @@ func cronJobMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
286289
}
287290
}),
288291
),
289-
*generator.NewFamilyGenerator(
292+
*generator.NewFamilyGeneratorWithStability(
290293
"kube_cronjob_spec_failed_job_history_limit",
291294
"Failed job history limit tells the controller how many failed jobs should be preserved.",
292295
metric.Gauge,
296+
basemetrics.ALPHA,
293297
"",
294298
wrapCronJobFunc(func(j *batchv1.CronJob) *metric.Family {
295299
ms := []*metric.Metric{}

internal/store/daemonset.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,10 +223,11 @@ func daemonSetMetricFamilies(allowAnnotationsList, allowLabelsList []string) []g
223223
}
224224
}),
225225
),
226-
*generator.NewFamilyGenerator(
226+
*generator.NewFamilyGeneratorWithStability(
227227
descDaemonSetAnnotationsName,
228228
descDaemonSetAnnotationsHelp,
229229
metric.Gauge,
230+
basemetrics.ALPHA,
230231
"",
231232
wrapDaemonSetFunc(func(d *v1.DaemonSet) *metric.Family {
232233
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", d.Annotations, allowAnnotationsList)

internal/store/deployment.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,10 +283,11 @@ func deploymentMetricFamilies(allowAnnotationsList, allowLabelsList []string) []
283283
}
284284
}),
285285
),
286-
*generator.NewFamilyGenerator(
286+
*generator.NewFamilyGeneratorWithStability(
287287
descDeploymentAnnotationsName,
288288
descDeploymentAnnotationsHelp,
289289
metric.Gauge,
290+
basemetrics.ALPHA,
290291
"",
291292
wrapDeploymentFunc(func(d *v1.Deployment) *metric.Family {
292293
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", d.Annotations, allowAnnotationsList)

internal/store/endpoint.go

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,10 +79,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
7979
}
8080
}),
8181
),
82-
*generator.NewFamilyGenerator(
82+
*generator.NewFamilyGeneratorWithStability(
8383
descEndpointAnnotationsName,
8484
descEndpointAnnotationsHelp,
8585
metric.Gauge,
86+
basemetrics.ALPHA,
8687
"",
8788
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
8889
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", e.Annotations, allowAnnotationsList)
@@ -116,10 +117,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
116117
}
117118
}),
118119
),
119-
*generator.NewFamilyGenerator(
120+
*generator.NewFamilyGeneratorWithStability(
120121
"kube_endpoint_address_available",
121122
"Number of addresses available in endpoint.",
122123
metric.Gauge,
124+
basemetrics.ALPHA,
123125
"v2.6.0",
124126
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
125127
var available int
@@ -136,10 +138,11 @@ func endpointMetricFamilies(allowAnnotationsList, allowLabelsList []string) []ge
136138
}
137139
}),
138140
),
139-
*generator.NewFamilyGenerator(
141+
*generator.NewFamilyGeneratorWithStability(
140142
"kube_endpoint_address_not_ready",
141143
"Number of addresses not ready in endpoint",
142144
metric.Gauge,
145+
basemetrics.ALPHA,
143146
"v2.6.0",
144147
wrapEndpointFunc(func(e *v1.Endpoints) *metric.Family {
145148
var notReady int

internal/store/horizontalpodautoscaler.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ var (
5555

5656
func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generator.FamilyGenerator {
5757
return []generator.FamilyGenerator{
58-
*generator.NewFamilyGenerator(
58+
*generator.NewFamilyGeneratorWithStability(
5959
"kube_horizontalpodautoscaler_info",
6060
"Information about this autoscaler.",
6161
metric.Gauge,
62+
basemetrics.ALPHA,
6263
"",
6364
wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family {
6465
labelKeys := []string{"scaletargetref_kind", "scaletargetref_name"}
@@ -126,10 +127,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
126127
}
127128
}),
128129
),
129-
*generator.NewFamilyGenerator(
130+
*generator.NewFamilyGeneratorWithStability(
130131
"kube_horizontalpodautoscaler_spec_target_metric",
131132
"The metric specifications used by this autoscaler when calculating the desired replica count.",
132133
metric.Gauge,
134+
basemetrics.ALPHA,
133135
"",
134136
wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family {
135137
ms := make([]*metric.Metric, 0, len(a.Spec.Metrics))
@@ -181,10 +183,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
181183
return &metric.Family{Metrics: ms}
182184
}),
183185
),
184-
*generator.NewFamilyGenerator(
186+
*generator.NewFamilyGeneratorWithStability(
185187
"kube_horizontalpodautoscaler_status_target_metric",
186188
"The current metric status used by this autoscaler when calculating the desired replica count.",
187189
metric.Gauge,
190+
basemetrics.ALPHA,
188191
"",
189192
wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family {
190193
ms := make([]*metric.Metric, 0, len(a.Status.CurrentMetrics))
@@ -268,10 +271,11 @@ func hpaMetricFamilies(allowAnnotationsList, allowLabelsList []string) []generat
268271
}
269272
}),
270273
),
271-
*generator.NewFamilyGenerator(
274+
*generator.NewFamilyGeneratorWithStability(
272275
descHorizontalPodAutoscalerAnnotationsName,
273276
descHorizontalPodAutoscalerAnnotationsHelp,
274277
metric.Gauge,
278+
basemetrics.ALPHA,
275279
"",
276280
wrapHPAFunc(func(a *autoscaling.HorizontalPodAutoscaler) *metric.Family {
277281
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", a.Annotations, allowAnnotationsList)

internal/store/ingress.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
6868
}}
6969
}),
7070
),
71-
*generator.NewFamilyGenerator(
71+
*generator.NewFamilyGeneratorWithStability(
7272
descIngressAnnotationsName,
7373
descIngressAnnotationsHelp,
7474
metric.Gauge,
75+
basemetrics.ALPHA,
7576
"",
7677
wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family {
7778
annotationKeys, annotationValues := createPrometheusLabelKeysValues("annotation", i.Annotations, allowAnnotationsList)
@@ -125,10 +126,11 @@ func ingressMetricFamilies(allowAnnotationsList, allowLabelsList []string) []gen
125126
}
126127
}),
127128
),
128-
*generator.NewFamilyGenerator(
129+
*generator.NewFamilyGeneratorWithStability(
129130
"kube_ingress_metadata_resource_version",
130131
"Resource version representing a specific version of ingress.",
131132
metric.Gauge,
133+
basemetrics.ALPHA,
132134
"",
133135
wrapIngressFunc(func(i *networkingv1.Ingress) *metric.Family {
134136
return &metric.Family{

0 commit comments

Comments
 (0)