Skip to content

Commit 2a8640b

Browse files
authored
Merge pull request kubernetes#94386 from JornShen/cleanup_testutil_metrics
clean up testutil/metrics.go
2 parents 35e235b + 9c8867f commit 2a8640b

File tree

1 file changed

+1
-23
lines changed
  • staging/src/k8s.io/component-base/metrics/testutil

1 file changed

+1
-23
lines changed

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

Lines changed: 1 addition & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ func ParseMetrics(data string, output *Metrics) error {
8686
continue
8787
}
8888
for _, metric := range v {
89-
name := string(metric.Metric[model.MetricNameLabel])
89+
name := string(metric.Metric[MetricNameLabel])
9090
(*output)[name] = append((*output)[name], metric)
9191
}
9292
}
@@ -101,28 +101,6 @@ func TextToMetricFamilies(in io.Reader) (map[string]*dto.MetricFamily, error) {
101101
return textParser.TextToMetricFamilies(in)
102102
}
103103

104-
// ExtractMetricSamples parses the prometheus metric samples from the input string.
105-
func ExtractMetricSamples(metricsBlob string) ([]*model.Sample, error) {
106-
dec := expfmt.NewDecoder(strings.NewReader(metricsBlob), expfmt.FmtText)
107-
decoder := expfmt.SampleDecoder{
108-
Dec: dec,
109-
Opts: &expfmt.DecodeOptions{},
110-
}
111-
112-
var samples []*model.Sample
113-
for {
114-
var v model.Vector
115-
if err := decoder.Decode(&v); err != nil {
116-
if err == io.EOF {
117-
// Expected loop termination condition.
118-
return samples, nil
119-
}
120-
return nil, err
121-
}
122-
samples = append(samples, v...)
123-
}
124-
}
125-
126104
// PrintSample returns formatted representation of metric Sample
127105
func PrintSample(sample *model.Sample) string {
128106
buf := make([]string, 0)

0 commit comments

Comments
 (0)