Skip to content

Commit 3842a92

Browse files
authored
Merge pull request kubernetes#89413 from zhouya0/remove_prometheus_references_from_etcd_version_monitor
Remove prometheus references from etcd version monitor
2 parents c1fc466 + 04d06d2 commit 3842a92

File tree

3 files changed

+12
-5
lines changed

3 files changed

+12
-5
lines changed

cluster/images/etcd-version-monitor/BUILD

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ go_library(
1717
importpath = "k8s.io/kubernetes/cluster/images/etcd-version-monitor",
1818
deps = [
1919
"//staging/src/k8s.io/component-base/metrics:go_default_library",
20+
"//staging/src/k8s.io/component-base/metrics/testutil:go_default_library",
2021
"//vendor/github.com/gogo/protobuf/proto:go_default_library",
2122
"//vendor/github.com/prometheus/client_model/go:go_default_library",
22-
"//vendor/github.com/prometheus/common/expfmt:go_default_library",
2323
"//vendor/github.com/spf13/pflag:go_default_library",
2424
"//vendor/k8s.io/klog:go_default_library",
2525
],

cluster/images/etcd-version-monitor/etcd-version-monitor.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,10 @@ import (
2727

2828
"github.com/gogo/protobuf/proto"
2929
dto "github.com/prometheus/client_model/go"
30-
"github.com/prometheus/common/expfmt"
3130
"github.com/spf13/pflag"
3231

3332
"k8s.io/component-base/metrics"
33+
"k8s.io/component-base/metrics/testutil"
3434
"k8s.io/klog"
3535
)
3636

@@ -271,9 +271,7 @@ func scrapeMetrics() (map[string]*dto.MetricFamily, error) {
271271
}
272272
defer resp.Body.Close()
273273

274-
// Parse the metrics in text format to a MetricFamily struct.
275-
var textParser expfmt.TextParser
276-
return textParser.TextToMetricFamilies(resp.Body)
274+
return testutil.TextToMetricFamilies(resp.Body)
277275
}
278276

279277
func renameMetric(mf *dto.MetricFamily, name string) {

staging/src/k8s.io/component-base/metrics/testutil/metrics.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ func ParseMetrics(data string, output *Metrics) error {
9292
}
9393
}
9494

95+
// TextToMetricFamilies reads 'in' as the simple and flat text-based exchange
96+
// format and creates MetricFamily proto messages. It returns the MetricFamily
97+
// proto messages in a map where the metric names are the keys, along with any
98+
// error encountered.
99+
func TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error) {
100+
var textParser expfmt.TextParser
101+
return textParser.TextToMetricFamilies(in)
102+
}
103+
95104
// ExtractMetricSamples parses the prometheus metric samples from the input string.
96105
func ExtractMetricSamples(metricsBlob string) ([]*model.Sample, error) {
97106
dec := expfmt.NewDecoder(strings.NewReader(metricsBlob), expfmt.FmtText)

0 commit comments

Comments
 (0)