Skip to content

Commit

Permalink
fix: Remove log output from benchmark
Browse files Browse the repository at this point in the history
Without this change Info logs appear in the benchmark

ok      k8s.io/kube-state-metrics/v2/pkg/allowdenylist  0.005s
I1106 08:50:22.006480  144965 builder.go:280] "Active resources" activeStoreNames="certificatesigningrequests,configmaps,cronjobs,daemonsets,deployments,endpoints,horizontalpodautoscalers,ingresses,jobs,leases,limitranges,mutatingwebhookconfigurations,namespaces,networkpolicies,nodes,persistentvolumeclaims,persistentvolumes,poddisruptionbudgets,pods,replicasets,replicationcontrollers,resourcequotas,secrets,services,statefulsets,storageclasses,validatingwebhookconfigurations,volumeattachments"
goos: linux
goarch: amd64
pkg: k8s.io/kube-state-metrics/v2/pkg/app
cpu: Intel(R) Core(TM) i7-1065G7 CPU @ 1.30GHz
BenchmarkKubeStateMetrics/GenerateMetrics-8                    1        1001291639 ns/op        67578008 B/op     582810 allocs/op
  • Loading branch information
mrueg committed Nov 6, 2024
1 parent fac6119 commit 6f57eff
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/app/server_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ package app
import (
"bytes"
"context"
"flag"
"fmt"
"io"
"net/http/httptest"
Expand All @@ -45,6 +46,7 @@ import (

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

"k8s.io/klog/v2"
"k8s.io/kube-state-metrics/v2/internal/store"
"k8s.io/kube-state-metrics/v2/pkg/allowdenylist"
"k8s.io/kube-state-metrics/v2/pkg/customresource"
Expand All @@ -70,6 +72,10 @@ func BenchmarkKubeStateMetrics(b *testing.B) {
b.Errorf("error injecting resources: %v", err)
}
ctx, cancel := context.WithCancel(context.Background())

klogFlags := flag.NewFlagSet("klog", flag.ExitOnError)
klog.InitFlags(klogFlags)
klogFlags.Set("logtostderr", "false")
defer cancel()
reg := prometheus.NewRegistry()

Expand Down

0 comments on commit 6f57eff

Please sign in to comment.