Skip to content

Commit

Permalink
Change default validation scheme to UTF8Validation
Browse files Browse the repository at this point in the history
fixes #723
  • Loading branch information
ywwg committed Nov 15, 2024
1 parent e25286d commit 435605e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
5 changes: 5 additions & 0 deletions model/alert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ import (
)

func TestAlertValidate(t *testing.T) {
oldScheme := NameValidationScheme
NameValidationScheme = LegacyValidation
defer func() {
NameValidationScheme = oldScheme
}()
ts := time.Now()

cases := []struct {
Expand Down
14 changes: 7 additions & 7 deletions model/metric.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ import (

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

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

0 comments on commit 435605e

Please sign in to comment.