diff --git a/lib/promrelabel/relabel.go b/lib/promrelabel/relabel.go index 38ab350c7..601a0297d 100644 --- a/lib/promrelabel/relabel.go +++ b/lib/promrelabel/relabel.go @@ -673,7 +673,7 @@ func SplitMetricNameToTokens(name string) []string { var nonAlphaNumChars = regexp.MustCompile(`[^a-zA-Z0-9]`) var labelNameSanitizer = bytesutil.NewFastStringTransformer(func(s string) string { - return unsupportedLabelNameChars.ReplaceAllString(s, "_") + return unsupportedLabelNameChars.ReplaceAllLiteralString(s, "_") }) var unsupportedLabelNameChars = regexp.MustCompile(`[^a-zA-Z0-9_]`) @@ -686,7 +686,7 @@ func SanitizeMetricName(value string) string { } var metricNameSanitizer = bytesutil.NewFastStringTransformer(func(s string) string { - return unsupportedMetricNameChars.ReplaceAllString(s, "_") + return unsupportedMetricNameChars.ReplaceAllLiteralString(s, "_") }) var unsupportedMetricNameChars = regexp.MustCompile(`[^a-zA-Z0-9_:]`) diff --git a/lib/promscrape/discoveryutils/utils.go b/lib/promscrape/discoveryutils/utils.go index 91a290056..08e867284 100644 --- a/lib/promscrape/discoveryutils/utils.go +++ b/lib/promscrape/discoveryutils/utils.go @@ -20,7 +20,7 @@ func SanitizeLabelName(name string) string { } var labelNamesSanitizer = bytesutil.NewFastStringTransformer(func(s string) string { - return invalidLabelCharRE.ReplaceAllString(s, "_") + return invalidLabelCharRE.ReplaceAllLiteralString(s, "_") }) var invalidLabelCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`) diff --git a/lib/protoparser/datadogutils/datadogutils.go b/lib/protoparser/datadogutils/datadogutils.go index 51cc79c07..d5c474727 100644 --- a/lib/protoparser/datadogutils/datadogutils.go +++ b/lib/protoparser/datadogutils/datadogutils.go @@ -44,9 +44,9 @@ func SanitizeName(name string) string { } var namesSanitizer = bytesutil.NewFastStringTransformer(func(s string) string { - s = unsupportedDatadogChars.ReplaceAllString(s, "_") - s = multiUnderscores.ReplaceAllString(s, "_") - s = underscoresWithDots.ReplaceAllString(s, ".") + s = unsupportedDatadogChars.ReplaceAllLiteralString(s, "_") + s = multiUnderscores.ReplaceAllLiteralString(s, "_") + s = underscoresWithDots.ReplaceAllLiteralString(s, ".") return s }) diff --git a/lib/querytracer/tracer_test.go b/lib/querytracer/tracer_test.go index d67336f91..b0e4c0973 100644 --- a/lib/querytracer/tracer_test.go +++ b/lib/querytracer/tracer_test.go @@ -221,7 +221,7 @@ func areEqualTracesSkipDuration(s1, s2 string) bool { } func zeroDurationsInTrace(s string) string { - return skipDurationRe.ReplaceAllString(s, " 0ms: ") + return skipDurationRe.ReplaceAllLiteralString(s, " 0ms: ") } var skipDurationRe = regexp.MustCompile(" [0-9.]+ms: ") @@ -233,7 +233,7 @@ func areEqualJSONTracesSkipDuration(s1, s2 string) bool { } func zeroJSONDurationsInTrace(s string) string { - return skipJSONDurationRe.ReplaceAllString(s, `"duration_msec":0`) + return skipJSONDurationRe.ReplaceAllLiteralString(s, `"duration_msec":0`) } var skipJSONDurationRe = regexp.MustCompile(`"duration_msec":[0-9.]+`)