Merge pull request #83610 from SataQiu/metrics-apiserver-20191008

Eliminate direct references to prometheus from apiserver admission
This commit is contained in:
Kubernetes Prow Robot 2019-10-11 13:42:03 -07:00 committed by GitHub
commit 30603a8b58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 5 deletions

View File

@ -25,7 +25,7 @@ go_test(
"//staging/src/k8s.io/apimachinery/pkg/runtime:go_default_library",
"//staging/src/k8s.io/apimachinery/pkg/runtime/schema:go_default_library",
"//staging/src/k8s.io/apiserver/pkg/admission:go_default_library",
"//vendor/github.com/prometheus/client_golang/prometheus:go_default_library",
"//staging/src/k8s.io/component-base/metrics/legacyregistry:go_default_library",
"//vendor/github.com/prometheus/client_model/go:go_default_library",
],
)

View File

@ -19,8 +19,8 @@ package metrics
import (
"testing"
"github.com/prometheus/client_golang/prometheus"
ptype "github.com/prometheus/client_model/go"
"k8s.io/component-base/metrics/legacyregistry"
)
func labelsMatch(metric *ptype.Metric, labelFilter map[string]string) bool {
@ -34,7 +34,7 @@ func labelsMatch(metric *ptype.Metric, labelFilter map[string]string) bool {
// expectFindMetric find a metric with the given name nad labels or reports a fatal test error.
func expectFindMetric(t *testing.T, name string, expectedLabels map[string]string) *ptype.Metric {
metrics, err := prometheus.DefaultGatherer.Gather()
metrics, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
t.Fatalf("Failed to gather metrics: %s", err)
}
@ -61,7 +61,7 @@ func expectFindMetric(t *testing.T, name string, expectedLabels map[string]strin
// expectHistogramCountTotal ensures that the sum of counts of metrics matching the labelFilter is as
// expected.
func expectHistogramCountTotal(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
metrics, err := prometheus.DefaultGatherer.Gather()
metrics, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
t.Fatalf("Failed to gather metrics: %s", err)
}
@ -93,7 +93,7 @@ func expectHistogramCountTotal(t *testing.T, name string, labelFilter map[string
// expectCounterValue ensures that the counts of metrics matching the labelFilter is as
// expected.
func expectCounterValue(t *testing.T, name string, labelFilter map[string]string, wantCount int) {
metrics, err := prometheus.DefaultGatherer.Gather()
metrics, err := legacyregistry.DefaultGatherer.Gather()
if err != nil {
t.Fatalf("Failed to gather metrics: %s", err)
}