Skip to content

Commit 3e482a3

Browse files
bwplotkaying-jeanne
authored andcommitted
Upgrade to prometheus/common 0.62.0 with breaking change (prometheus#1712)
common 0.62.0 switches NameValidationScheme global variable to UTF8Validation. While relaxing validation this will likely yield test failures downstream. It's unfortunate, but the alternatives were worse: prometheus/common#724 Good news is that client_golang should work with older common deps and callers can easily change model.NameValidationScheme value to old value to solve any compatibility issues. Signed-off-by: bwplotka <[email protected]>
1 parent 54431dd commit 3e482a3

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

prometheus/counter_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,7 @@ func TestCounterExemplar(t *testing.T) {
291291
}
292292
}()
293293
// Should panic because of invalid label name.
294-
counter.AddWithExemplar(42, Labels{":o)": "smile"})
294+
counter.AddWithExemplar(42, Labels{"in\x80valid": "smile"})
295295
return nil
296296
}
297297
if addExemplarWithInvalidLabel() == nil {

prometheus/internal/go_runtime_metrics.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ func RuntimeMetricsToProm(d *metrics.Description) (string, string, string, bool)
6666
name += "_total"
6767
}
6868

69-
valid := model.IsValidMetricName(model.LabelValue(namespace + "_" + subsystem + "_" + name))
69+
// Our current conversion moves to legacy naming, so use legacy validation.
70+
valid := model.IsValidLegacyMetricName(namespace + "_" + subsystem + "_" + name)
7071
switch d.Kind {
7172
case metrics.KindUint64:
7273
case metrics.KindFloat64:

prometheus/promhttp/instrument_server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ func TestLabelCheck(t *testing.T) {
6666
},
6767
"all labels used with an invalid const label name": {
6868
varLabels: []string{"code", "method"},
69-
constLabels: []string{"in-valid", "bar"},
69+
constLabels: []string{"in\x80valid", "bar"},
7070
curriedLabels: []string{"dings", "bums"},
7171
dynamicLabels: []string{"dyn", "amics"},
7272
ok: false,
@@ -120,14 +120,14 @@ func TestLabelCheck(t *testing.T) {
120120
ok: false,
121121
},
122122
"invalid name and otherwise empty": {
123-
metricName: "in-valid",
123+
metricName: "in\x80valid",
124124
varLabels: []string{},
125125
constLabels: []string{},
126126
curriedLabels: []string{},
127127
ok: false,
128128
},
129129
"invalid name with all the otherwise valid labels": {
130-
metricName: "in-valid",
130+
metricName: "in\x80valid",
131131
varLabels: []string{"code", "method"},
132132
constLabels: []string{"foo", "bar"},
133133
curriedLabels: []string{"dings", "bums"},

prometheus/push/push_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ func TestPush(t *testing.T) {
229229
t.Error("push with grouping contained in metrics succeeded")
230230
}
231231
if err := New(pgwOK.URL, "testjob").
232-
Grouping("foo-bar", "bums").
232+
Grouping("foo\x80bar", "bums").
233233
Collector(metric1).
234234
Collector(metric2).
235235
Push(); err == nil {

prometheus/wrap_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ func TestWrap(t *testing.T) {
153153
output: []Collector{simpleGge, labeledPreCnt},
154154
},
155155
"wrap counter with invalid prefix": {
156-
prefix: "1+1",
156+
prefix: "1\x801",
157157
preRegister: []Collector{simpleGge},
158158
toRegister: []struct {
159159
collector Collector
@@ -163,7 +163,7 @@ func TestWrap(t *testing.T) {
163163
},
164164
"wrap counter with invalid label": {
165165
preRegister: []Collector{simpleGge},
166-
labels: Labels{"42": "bar"},
166+
labels: Labels{"\x80": "bar"},
167167
toRegister: []struct {
168168
collector Collector
169169
registrationFails bool

0 commit comments

Comments
 (0)