mirror of
https://github.com/hanzoai/deploy.git
synced 2026-10-07 08:44:50 +00:00
* add appset metrics Signed-off-by: Ilia Medvedev <[email protected]> * cleanup Signed-off-by: Ilia Medvedev <[email protected]> * cleanup Signed-off-by: Ilia Medvedev <[email protected]> * address comments and fix test parallelism issue Signed-off-by: Ilia Medvedev <[email protected]> * fix controller unit tests - add metrics to tests Signed-off-by: Ilia Medvedev <[email protected]> * lint Signed-off-by: Ilia Medvedev <[email protected]> * lint Signed-off-by: Ilia Medvedev <[email protected]> * Add FakeAppsetMetrics to clear up registry and create metrics structure for tests without causing collisions Signed-off-by: Ilia Medvedev <[email protected]> * Change fake metrics implementation Signed-off-by: Ilia Medvedev <[email protected]> * Fix typo Signed-off-by: Ilia Medvedev <[email protected]> --------- Signed-off-by: Ilia Medvedev <[email protected]> Co-authored-by: pashakostohrys <[email protected]>
21 lines
564 B
Go
21 lines
564 B
Go
package metrics
|
|
|
|
import (
|
|
"fmt"
|
|
"regexp"
|
|
)
|
|
|
|
// Prometheus invalid labels, more info: https://prometheus.io/docs/concepts/data_model/#metric-names-and-labels.
|
|
var invalidPromLabelChars = regexp.MustCompile(`[^a-zA-Z0-9_]`)
|
|
|
|
func NormalizeLabels(prefix string, labels []string) []string {
|
|
results := []string{}
|
|
for _, label := range labels {
|
|
// prometheus labels don't accept dash in their name
|
|
curr := invalidPromLabelChars.ReplaceAllString(label, "_")
|
|
result := fmt.Sprintf("%s_%s", prefix, curr)
|
|
results = append(results, result)
|
|
}
|
|
return results
|
|
}
|