Skip to content

Commit babb979

Browse files
committed
Change default validation scheme to UTF8Validation
fixes #723 Signed-off-by: Owen Williams <[email protected]>
1 parent e25286d commit babb979

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

Diff for: 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 {

Diff for: model/metric.go

+7-7
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ import (
2727

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

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

0 commit comments

Comments
 (0)