mirror of
https://github.com/hanzoai/traces.git
synced 2026-10-30 18:20:41 +00:00
* config: validate more fields and duplicate labels in the user API - detect duplicate labels after sanitization in span-metrics and service-graphs dimensions - add validation for dimension mappings - add validation for host-info metric name * add changelog entry
23 lines
481 B
Go
23 lines
481 B
Go
package validation
|
|
|
|
import (
|
|
"github.com/prometheus/prometheus/util/strutil"
|
|
)
|
|
|
|
type SanitizeFn func(string) string
|
|
|
|
func SanitizeLabelNameWithCollisions(name string, dimensions map[string]struct{}, sanitizeFn SanitizeFn) string {
|
|
sanitized := sanitizeFn(name)
|
|
|
|
// check if same label as intrinsics
|
|
if _, ok := dimensions[sanitized]; ok {
|
|
return "__" + sanitized
|
|
}
|
|
|
|
return sanitized
|
|
}
|
|
|
|
func SanitizeLabelName(name string) string {
|
|
return strutil.SanitizeLabelName(name)
|
|
}
|