Adding upstream version 1.34.4.
Signed-off-by: Daniel Baumann <daniel@debian.org>
This commit is contained in:
parent
e393c3af3f
commit
4978089aab
4963 changed files with 677545 additions and 0 deletions
31
plugins/serializers/wavefront/replacers.go
Normal file
31
plugins/serializers/wavefront/replacers.go
Normal file
|
@ -0,0 +1,31 @@
|
|||
package wavefront
|
||||
|
||||
import "strings"
|
||||
|
||||
// catch many of the invalid chars that could appear in a metric or tag name
|
||||
var sanitizedChars = strings.NewReplacer(
|
||||
"!", "-", "@", "-", "#", "-", "$", "-", "%", "-", "^", "-", "&", "-",
|
||||
"*", "-", "(", "-", ")", "-", "+", "-", "`", "-", "'", "-", "\"", "-",
|
||||
"[", "-", "]", "-", "{", "-", "}", "-", ":", "-", ";", "-", "<", "-",
|
||||
">", "-", ",", "-", "?", "-", "/", "-", "\\", "-", "|", "-", " ", "-",
|
||||
"=", "-",
|
||||
)
|
||||
|
||||
// catch many of the invalid chars that could appear in a metric or tag name
|
||||
var strictSanitizedChars = strings.NewReplacer(
|
||||
"!", "-", "@", "-", "#", "-", "$", "-", "%", "-", "^", "-", "&", "-",
|
||||
"*", "-", "(", "-", ")", "-", "+", "-", "`", "-", "'", "-", "\"", "-",
|
||||
"[", "-", "]", "-", "{", "-", "}", "-", ":", "-", ";", "-", "<", "-",
|
||||
">", "-", "?", "-", "\\", "-", "|", "-", " ", "-", "=", "-",
|
||||
)
|
||||
|
||||
var tagValueReplacer = strings.NewReplacer("\"", "\\\"", "*", "-")
|
||||
|
||||
var pathReplacer = strings.NewReplacer("_", ".")
|
||||
|
||||
func Sanitize(strict bool, val string) string {
|
||||
if strict {
|
||||
return strictSanitizedChars.Replace(val)
|
||||
}
|
||||
return sanitizedChars.Replace(val)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue