@@ -27,13 +27,25 @@ import (
27
27
)
28
28
29
29
var (
30
- // NameValidationScheme determines the method of name validation to be used by
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.
30
+ // NameValidationScheme determines the global default method of the name
31
+ // validation to be used by all calls to IsValidMetricName() and LabelName
32
+ // IsValid().
33
+ //
34
+ // Deprecated: This variable should not be used and might be removed in the
35
+ // far future. If you wish to stick to the legacy name validation use
36
+ // `IsValidLegacyMetricName()` and `LabelName.IsValidLegacy()` methods
37
+ // instead. This variable is here as an escape hatch for emergency cases,
38
+ // given the recent change from `LegacyValidation` to `UTF8Validation`, e.g.,
39
+ // to delay UTF-8 migrations in time or aid in debugging unforeseen results of
40
+ // the change. In such a case, a temporary assignment to `LegacyValidation`
41
+ // value in the `init()` function in your main.go or so, could be considered.
42
+ //
43
+ // Historically we opted for a global variable for feature gating different
44
+ // validation schemes in operations that were not otherwise easily adjustable
45
+ // (e.g. Labels yaml unmarshaling). That could have been a mistake, a separate
46
+ // Labels structure or package might have been a better choice. Given the
47
+ // change was made and many upgraded the common already, we live this as-is
48
+ // with this warning and learning for the future.
37
49
NameValidationScheme = UTF8Validation
38
50
39
51
// NameEscapingScheme defines the default way that names will be escaped when
50
62
type ValidationScheme int
51
63
52
64
const (
53
- // LegacyValidation is a setting that requirets that metric and label names
65
+ // LegacyValidation is a setting that requires that all metric and label names
54
66
// conform to the original Prometheus character requirements described by
55
67
// MetricNameRE and LabelNameRE.
56
68
LegacyValidation ValidationScheme = iota
0 commit comments