Bringing function and regexp names back to original

Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@intel.com>
This commit is contained in:
Maciej "Iwan" Iwanowski 2020-04-17 09:03:13 +02:00
parent 18902209dc
commit 39ae19d514
No known key found for this signature in database
GPG Key ID: 2484258A4DD3EE84

View File

@ -1684,7 +1684,7 @@ func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric)
containerLabels := c.containerLabelsFunc(cont) containerLabels := c.containerLabelsFunc(cont)
for l := range rawLabels { for l := range rawLabels {
duplicate := false duplicate := false
sl := sanitizeName(l) sl := sanitizeLabelName(l)
for _, x := range labels { for _, x := range labels {
if sl == x { if sl == x {
duplicate = true duplicate = true
@ -1746,7 +1746,7 @@ func (c *PrometheusCollector) collectContainersInfo(ch chan<- prometheus.Metric)
copy(clabels, labels) copy(clabels, labels)
copy(cvalues, values) copy(cvalues, values)
for label, value := range metric.Labels { for label, value := range metric.Labels {
clabels = append(clabels, sanitizeName("app_"+label)) clabels = append(clabels, sanitizeLabelName("app_"+label))
cvalues = append(cvalues, value) cvalues = append(cvalues, value)
} }
desc := prometheus.NewDesc(metricLabel, "Custom application metric.", clabels, nil) desc := prometheus.NewDesc(metricLabel, "Custom application metric.", clabels, nil)
@ -1780,8 +1780,8 @@ func specMemoryValue(v uint64) float64 {
var invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`) var invalidNameCharRE = regexp.MustCompile(`[^a-zA-Z0-9_]`)
// sanitizeName replaces anything that doesn't match // sanitizeLabelName replaces anything that doesn't match
// client_label.LabelNameRE with an underscore. // client_label.LabelNameRE with an underscore.
func sanitizeName(name string) string { func sanitizeLabelName(name string) string {
return invalidNameCharRE.ReplaceAllString(name, "_") return invalidNameCharRE.ReplaceAllString(name, "_")
} }