From 0c4f95d3d09ca6d77d7f25fda6588a5d8d49f608 Mon Sep 17 00:00:00 2001 From: Joel Whittaker-Smith Date: Fri, 25 Sep 2020 22:04:05 +0200 Subject: [PATCH] Now references closure scoped family generator Signed-off-by: Joel Whittaker-Smith --- main_test.go | 7 ++++++- pkg/metric_generator/generator.go | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/main_test.go b/main_test.go index 6236c76161..2d0acdfdde 100644 --- a/main_test.go +++ b/main_test.go @@ -138,7 +138,12 @@ func TestFullScrapeCycle(t *testing.T) { t.Fatal(err) } builder.WithAllowDenyList(l) - builder.WithAllowLabels(map[string][]string{}) + builder.WithAllowLabels(map[string][]string{ + "kube_pod_labels": { + "namespace", + "pod", + }, + }) handler := metricshandler.New(&options.Options{}, kubeClient, builder, false) handler.ConfigureSharding(ctx, 0, 1) diff --git a/pkg/metric_generator/generator.go b/pkg/metric_generator/generator.go index a8958f031e..3c95ce5de0 100644 --- a/pkg/metric_generator/generator.go +++ b/pkg/metric_generator/generator.go @@ -135,7 +135,7 @@ func FilterMetricFamiliesLabels(allowLabels allowLabels, families []FamilyGenera metricFamily := familyGenerator.GenerateFunc(obj) for _, m := range metricFamily.Metrics { - m.LabelKeys, m.LabelValues = allowLabels.Allowed(f.Name, m.LabelKeys, m.LabelValues) + m.LabelKeys, m.LabelValues = allowLabels.Allowed(familyGenerator.Name, m.LabelKeys, m.LabelValues) } return metricFamily }