update vendor prometheus/client_golang to newest release

pull/564/head
danielqsj 2019-02-22 07:46:31 -07:00
parent 1eb8d3b5c5
commit c6a16d6017
10 changed files with 74 additions and 50 deletions

16
Godeps/Godeps.json generated
View File

@ -3023,23 +3023,23 @@
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus", "ImportPath": "github.com/prometheus/client_golang/prometheus",
"Comment": "v0.9.1", "Comment": "v0.9.2",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/internal", "ImportPath": "github.com/prometheus/client_golang/prometheus/internal",
"Comment": "v0.9.1", "Comment": "v0.9.2",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp", "ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp",
"Comment": "v0.9.1", "Comment": "v0.9.2",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/testutil", "ImportPath": "github.com/prometheus/client_golang/prometheus/testutil",
"Comment": "v0.9.1", "Comment": "v0.9.2",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_model/go", "ImportPath": "github.com/prometheus/client_model/go",

View File

@ -572,15 +572,18 @@
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus", "ImportPath": "github.com/prometheus/client_golang/prometheus",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/internal", "ImportPath": "github.com/prometheus/client_golang/prometheus/internal",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp", "ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_model/go", "ImportPath": "github.com/prometheus/client_model/go",

View File

@ -552,15 +552,18 @@
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus", "ImportPath": "github.com/prometheus/client_golang/prometheus",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/internal", "ImportPath": "github.com/prometheus/client_golang/prometheus/internal",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp", "ImportPath": "github.com/prometheus/client_golang/prometheus/promhttp",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_model/go", "ImportPath": "github.com/prometheus/client_model/go",

View File

@ -220,11 +220,13 @@
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus", "ImportPath": "github.com/prometheus/client_golang/prometheus",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/internal", "ImportPath": "github.com/prometheus/client_golang/prometheus/internal",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_model/go", "ImportPath": "github.com/prometheus/client_model/go",

View File

@ -204,11 +204,13 @@
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus", "ImportPath": "github.com/prometheus/client_golang/prometheus",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_golang/prometheus/internal", "ImportPath": "github.com/prometheus/client_golang/prometheus/internal",
"Rev": "abad2d1bd44235a26707c172eab6bca5bf2dbad3" "Comment": "v0.9.2",
"Rev": "505eaef017263e299324067d40ca2c48f6a2cf50"
}, },
{ {
"ImportPath": "github.com/prometheus/client_model/go", "ImportPath": "github.com/prometheus/client_model/go",

View File

@ -93,7 +93,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// First add only the const label names and sort them... // First add only the const label names and sort them...
for labelName := range constLabels { for labelName := range constLabels {
if !checkLabelName(labelName) { if !checkLabelName(labelName) {
d.err = fmt.Errorf("%q is not a valid label name", labelName) d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
return d return d
} }
labelNames = append(labelNames, labelName) labelNames = append(labelNames, labelName)
@ -115,7 +115,7 @@ func NewDesc(fqName, help string, variableLabels []string, constLabels Labels) *
// dimension with a different mix between preset and variable labels. // dimension with a different mix between preset and variable labels.
for _, labelName := range variableLabels { for _, labelName := range variableLabels {
if !checkLabelName(labelName) { if !checkLabelName(labelName) {
d.err = fmt.Errorf("%q is not a valid label name", labelName) d.err = fmt.Errorf("%q is not a valid label name for metric %q", labelName, fqName)
return d return d
} }
labelNames = append(labelNames, "$"+labelName) labelNames = append(labelNames, "$"+labelName)

View File

@ -872,7 +872,13 @@ func checkMetricConsistency(
h = hashAddByte(h, separatorByte) h = hashAddByte(h, separatorByte)
// Make sure label pairs are sorted. We depend on it for the consistency // Make sure label pairs are sorted. We depend on it for the consistency
// check. // check.
sort.Sort(labelPairSorter(dtoMetric.Label)) if !sort.IsSorted(labelPairSorter(dtoMetric.Label)) {
// We cannot sort dtoMetric.Label in place as it is immutable by contract.
copiedLabels := make([]*dto.LabelPair, len(dtoMetric.Label))
copy(copiedLabels, dtoMetric.Label)
sort.Sort(labelPairSorter(copiedLabels))
dtoMetric.Label = copiedLabels
}
for _, lp := range dtoMetric.Label { for _, lp := range dtoMetric.Label {
h = hashAdd(h, lp.GetName()) h = hashAdd(h, lp.GetName())
h = hashAddByte(h, separatorByte) h = hashAddByte(h, separatorByte)
@ -903,8 +909,8 @@ func checkDescConsistency(
} }
// Is the desc consistent with the content of the metric? // Is the desc consistent with the content of the metric?
lpsFromDesc := make([]*dto.LabelPair, 0, len(dtoMetric.Label)) lpsFromDesc := make([]*dto.LabelPair, len(desc.constLabelPairs), len(dtoMetric.Label))
lpsFromDesc = append(lpsFromDesc, desc.constLabelPairs...) copy(lpsFromDesc, desc.constLabelPairs)
for _, l := range desc.variableLabels { for _, l := range desc.variableLabels {
lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{ lpsFromDesc = append(lpsFromDesc, &dto.LabelPair{
Name: proto.String(l), Name: proto.String(l),

View File

@ -37,7 +37,6 @@ import (
"bytes" "bytes"
"fmt" "fmt"
"io" "io"
"reflect"
"github.com/prometheus/common/expfmt" "github.com/prometheus/common/expfmt"
@ -125,38 +124,43 @@ func CollectAndCompare(c prometheus.Collector, expected io.Reader, metricNames .
// exposition format. If any metricNames are provided, only metrics with those // exposition format. If any metricNames are provided, only metrics with those
// names are compared. // names are compared.
func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...string) error { func GatherAndCompare(g prometheus.Gatherer, expected io.Reader, metricNames ...string) error {
metrics, err := g.Gather() got, err := g.Gather()
if err != nil { if err != nil {
return fmt.Errorf("gathering metrics failed: %s", err) return fmt.Errorf("gathering metrics failed: %s", err)
} }
if metricNames != nil { if metricNames != nil {
metrics = filterMetrics(metrics, metricNames) got = filterMetrics(got, metricNames)
} }
var tp expfmt.TextParser var tp expfmt.TextParser
expectedMetrics, err := tp.TextToMetricFamilies(expected) wantRaw, err := tp.TextToMetricFamilies(expected)
if err != nil { if err != nil {
return fmt.Errorf("parsing expected metrics failed: %s", err) return fmt.Errorf("parsing expected metrics failed: %s", err)
} }
want := internal.NormalizeMetricFamilies(wantRaw)
if !reflect.DeepEqual(metrics, internal.NormalizeMetricFamilies(expectedMetrics)) { return compare(got, want)
// Encode the gathered output to the readable text format for comparison. }
var buf1 bytes.Buffer
enc := expfmt.NewEncoder(&buf1, expfmt.FmtText)
for _, mf := range metrics {
if err := enc.Encode(mf); err != nil {
return fmt.Errorf("encoding result failed: %s", err)
}
}
// Encode normalized expected metrics again to generate them in the same ordering
// the registry does to spot differences more easily.
var buf2 bytes.Buffer
enc = expfmt.NewEncoder(&buf2, expfmt.FmtText)
for _, mf := range internal.NormalizeMetricFamilies(expectedMetrics) {
if err := enc.Encode(mf); err != nil {
return fmt.Errorf("encoding result failed: %s", err)
}
}
// compare encodes both provided slices of metric families into the text format,
// compares their string message, and returns an error if they do not match.
// The error contains the encoded text of both the desired and the actual
// result.
func compare(got, want []*dto.MetricFamily) error {
var gotBuf, wantBuf bytes.Buffer
enc := expfmt.NewEncoder(&gotBuf, expfmt.FmtText)
for _, mf := range got {
if err := enc.Encode(mf); err != nil {
return fmt.Errorf("encoding gathered metrics failed: %s", err)
}
}
enc = expfmt.NewEncoder(&wantBuf, expfmt.FmtText)
for _, mf := range want {
if err := enc.Encode(mf); err != nil {
return fmt.Errorf("encoding expected metrics failed: %s", err)
}
}
if wantBuf.String() != gotBuf.String() {
return fmt.Errorf(` return fmt.Errorf(`
metric output does not match expectation; want: metric output does not match expectation; want:
@ -165,7 +169,8 @@ metric output does not match expectation; want:
got: got:
%s %s
`, buf2.String(), buf1.String()) `, wantBuf.String(), gotBuf.String())
} }
return nil return nil
} }

View File

@ -39,13 +39,16 @@ func NewTimer(o Observer) *Timer {
// ObserveDuration records the duration passed since the Timer was created with // ObserveDuration records the duration passed since the Timer was created with
// NewTimer. It calls the Observe method of the Observer provided during // NewTimer. It calls the Observe method of the Observer provided during
// construction with the duration in seconds as an argument. ObserveDuration is // construction with the duration in seconds as an argument. The observed
// usually called with a defer statement. // duration is also returned. ObserveDuration is usually called with a defer
// statement.
// //
// Note that this method is only guaranteed to never observe negative durations // Note that this method is only guaranteed to never observe negative durations
// if used with Go1.9+. // if used with Go1.9+.
func (t *Timer) ObserveDuration() { func (t *Timer) ObserveDuration() time.Duration {
d := time.Since(t.begin)
if t.observer != nil { if t.observer != nil {
t.observer.Observe(time.Since(t.begin).Seconds()) t.observer.Observe(d.Seconds())
} }
return d
} }

0
vendor/k8s.io/kube-openapi/pkg/generators/rules/OWNERS generated vendored Normal file → Executable file
View File