From 712fca0cbd843bea9457898a498bc85efd9bba6a Mon Sep 17 00:00:00 2001 From: David Ashpole Date: Fri, 6 Sep 2024 14:35:18 +0000 Subject: [PATCH] switch to NameEscapingScheme --- exporters/prometheus/config.go | 2 +- exporters/prometheus/exporter.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/exporters/prometheus/config.go b/exporters/prometheus/config.go index c0b82c678010..660675dd6207 100644 --- a/exporters/prometheus/config.go +++ b/exporters/prometheus/config.go @@ -134,7 +134,7 @@ func WithNamespace(ns string) Option { return optionFunc(func(cfg config) config { if model.NameValidationScheme != model.UTF8Validation { // Only sanitize if prometheus does not support UTF-8. - ns = model.EscapeName(ns, model.UnderscoreEscaping) + ns = model.EscapeName(ns, model.NameEscapingScheme) } if !strings.HasSuffix(ns, "_") { // namespace and metric names should be separated with an underscore, diff --git a/exporters/prometheus/exporter.go b/exporters/prometheus/exporter.go index 2974ca680e85..b0f5f3730d51 100644 --- a/exporters/prometheus/exporter.go +++ b/exporters/prometheus/exporter.go @@ -316,7 +316,7 @@ func getAttrs(attrs attribute.Set, ks, vs [2]string, resourceKV keyVals) ([]stri keysMap := make(map[string][]string) for itr.Next() { kv := itr.Attribute() - key := model.EscapeName(string(kv.Key), model.UnderscoreEscaping) + key := model.EscapeName(string(kv.Key), model.NameEscapingScheme) if _, ok := keysMap[key]; !ok { keysMap[key] = []string{kv.Value.Emit()} } else { @@ -397,7 +397,7 @@ func (c *collector) getName(m metricdata.Metrics, typ *dto.MetricType) string { name := m.Name if model.NameValidationScheme != model.UTF8Validation { // Only sanitize if prometheus does not support UTF-8. - name = model.EscapeName(name, model.UnderscoreEscaping) + name = model.EscapeName(name, model.NameEscapingScheme) } addCounterSuffix := !c.withoutCounterSuffixes && *typ == dto.MetricType_COUNTER if addCounterSuffix {