Bringing function and regexp names back to original
Signed-off-by: Maciej "Iwan" Iwanowski <maciej.iwanowski@intel.com>
This commit is contained in:
parent
18902209dc
commit
39ae19d514
@ -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, "_")
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user