Skip to content

Commit 1a822a8

Browse files
authored
Upgrade to prometheus/common 0.62.0 with breaking change (#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 <bwplotka@gmail.com>
1 parent 7b39d01 commit 1a822a8

File tree

7 files changed

+15
-14
lines changed

7 files changed

+15
-14
lines changed

go.mod

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ require (
1010
github.com/klauspost/compress v1.17.11
1111
github.com/kylelemons/godebug v1.1.0
1212
github.com/prometheus/client_model v0.6.1
13-
github.com/prometheus/common v0.61.0
13+
github.com/prometheus/common v0.62.0
1414
github.com/prometheus/procfs v0.15.1
1515
golang.org/x/sys v0.28.0
1616
google.golang.org/protobuf v1.36.1
@@ -23,7 +23,7 @@ require (
2323
github.com/modern-go/reflect2 v1.0.2 // indirect
2424
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect
2525
github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f // indirect
26-
golang.org/x/net v0.32.0 // indirect
26+
golang.org/x/net v0.33.0 // indirect
2727
golang.org/x/oauth2 v0.24.0 // indirect
2828
golang.org/x/text v0.21.0 // indirect
2929
gopkg.in/yaml.v2 v2.4.0 // indirect

go.sum

+4-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
3535
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
3636
github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E=
3737
github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY=
38-
github.com/prometheus/common v0.61.0 h1:3gv/GThfX0cV2lpO7gkTUwZru38mxevy90Bj8YFSRQQ=
39-
github.com/prometheus/common v0.61.0/go.mod h1:zr29OCN/2BsJRaFwG8QOBr41D6kkchKbpeNH7pAjb/s=
38+
github.com/prometheus/common v0.62.0 h1:xasJaQlnWAeyHdUBeGjXmutelfJHWMRr+Fg4QszZ2Io=
39+
github.com/prometheus/common v0.62.0/go.mod h1:vyBcEuLSvWos9B1+CyL7JZ2up+uFzXhkqml0W5zIY1I=
4040
github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc=
4141
github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk=
4242
github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs=
@@ -46,8 +46,8 @@ github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+
4646
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
4747
github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA=
4848
github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY=
49-
golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI=
50-
golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs=
49+
golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I=
50+
golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4=
5151
golang.org/x/oauth2 v0.24.0 h1:KTBBxWqUa0ykRPLtV69rRto9TLXcqYkeswu48x/gvNE=
5252
golang.org/x/oauth2 v0.24.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI=
5353
golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA=

prometheus/counter_test.go

+1-1
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

+2-1
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

+3-3
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

+1-1
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

+2-2
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)