Skip to content

Commit

Permalink
Merge pull request #2157 from chrischdi/pr-info-no-suffix-spam
Browse files Browse the repository at this point in the history
fix: custommetrics: log no _info suffix in name only once per reading the configuration
  • Loading branch information
k8s-ci-robot committed Aug 18, 2023
2 parents aff4d97 + 59860ab commit 7ab0612
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
4 changes: 4 additions & 0 deletions pkg/customresourcestate/registry_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ func compileCommon(c MetricMeta) (*compiledCommon, error) {
func compileFamily(f Generator, resource Resource) (*compiledFamily, error) {
labels := resource.Labels.Merge(f.Labels)

if f.Each.Type == MetricTypeInfo && !strings.HasSuffix(f.Name, "_info") {
klog.InfoS("Info metric does not have _info suffix", "gvk", resource.GroupVersionKind.String(), "name", f.Name)
}

metric, err := newCompiledMetric(f.Each)
if err != nil {
return nil, fmt.Errorf("compiling metric: %w", err)
Expand Down
5 changes: 0 additions & 5 deletions pkg/metric_generator/generator.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import (
"strings"

basemetrics "k8s.io/component-base/metrics"
"k8s.io/klog/v2"

"k8s.io/kube-state-metrics/v2/pkg/metric"
)
Expand Down Expand Up @@ -74,10 +73,6 @@ func (g *FamilyGenerator) Generate(obj interface{}) *metric.Family {
family := g.GenerateFunc(obj)
family.Name = g.Name
family.Type = g.Type
// OpenMetrics spec requires that all Info metrics have a _info suffix.
if family.Type == metric.Info && !strings.HasSuffix(family.Name, "_info") {
klog.InfoS("Info metric %s does not have _info suffix", family.Name)
}
return family
}

Expand Down

0 comments on commit 7ab0612

Please sign in to comment.