...
1
16
17 package feature
18
19 import (
20 "context"
21
22 k8smetrics "k8s.io/component-base/metrics"
23 "k8s.io/component-base/metrics/legacyregistry"
24 )
25
26 var (
27
28 featureInfo = k8smetrics.NewGaugeVec(
29 &k8smetrics.GaugeOpts{
30 Namespace: "kubernetes",
31 Name: "feature_enabled",
32 Help: "This metric records the data about the stage and enablement of a k8s feature.",
33 StabilityLevel: k8smetrics.BETA,
34 },
35 []string{"name", "stage"},
36 )
37 )
38
39 func init() {
40 legacyregistry.MustRegister(featureInfo)
41 }
42
43 func ResetFeatureInfoMetric() {
44 featureInfo.Reset()
45 }
46
47 func RecordFeatureInfo(ctx context.Context, name string, stage string, enabled bool) {
48 value := 0.0
49 if enabled {
50 value = 1.0
51 }
52 featureInfo.WithContext(ctx).WithLabelValues(name, stage).Set(value)
53 }
54
View as plain text