Skip to content

Commit

Permalink
Merge pull request #1240 from jw-s/bugfix/fix-filter-label-function-c…
Browse files Browse the repository at this point in the history
…losure

Reference closure scoped family generator
  • Loading branch information
k8s-ci-robot authored Sep 29, 2020
2 parents a18b988 + a112553 commit 8772ad3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
7 changes: 6 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion pkg/metric_generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down

0 comments on commit 8772ad3

Please sign in to comment.