Skip to content

Commit cf5f48f

Browse files
authoredDec 5, 2024
Change default validation scheme to UTF8Validation (prometheus#724)
fixes prometheus#723 Signed-off-by: Owen Williams <owen.williams@grafana.com>
1 parent 7b484e9 commit cf5f48f

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed
 

‎model/alert_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,11 @@ import (
2222
)
2323

2424
func TestAlertValidate(t *testing.T) {
25+
oldScheme := NameValidationScheme
26+
NameValidationScheme = LegacyValidation
27+
defer func() {
28+
NameValidationScheme = oldScheme
29+
}()
2530
ts := time.Now()
2631

2732
cases := []struct {

‎model/metric.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,13 @@ import (
2828

2929
var (
3030
// NameValidationScheme determines the method of name validation to be used by
31-
// all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8 mode
32-
// in isolation from other components that don't support UTF-8 may result in
33-
// bugs or other undefined behavior. This value is intended to be set by
34-
// UTF-8-aware binaries as part of their startup. To avoid need for locking,
35-
// this value should be set once, ideally in an init(), before multiple
36-
// goroutines are started.
37-
NameValidationScheme = LegacyValidation
31+
// all calls to IsValidMetricName() and LabelName IsValid(). Setting UTF-8
32+
// mode in isolation from other components that don't support UTF-8 may result
33+
// in bugs or other undefined behavior. This value can be set to
34+
// LegacyValidation during startup if a binary is not UTF-8-aware binaries. To
35+
// avoid need for locking, this value should be set once, ideally in an
36+
// init(), before multiple goroutines are started.
37+
NameValidationScheme = UTF8Validation
3838

3939
// NameEscapingScheme defines the default way that names will be escaped when
4040
// presented to systems that do not support UTF-8 names. If the Content-Type

0 commit comments

Comments
 (0)
Please sign in to comment.