From c8deb934579c22b543555a064f7d97e25c13f7be Mon Sep 17 00:00:00 2001 From: smithclay Date: Thu, 13 Jun 2024 15:46:53 -0700 Subject: [PATCH] normalize metadata --- .../components/servicenowexporter/servicenow.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/collector/components/servicenowexporter/servicenow.go b/collector/components/servicenowexporter/servicenow.go index dd85dd7..08731c0 100644 --- a/collector/components/servicenowexporter/servicenow.go +++ b/collector/components/servicenowexporter/servicenow.go @@ -202,7 +202,17 @@ func (e *serviceNowProducer) writeNumberDataPoints(metricName string, scope stri func ci2metricAttrs(rAttrs pcommon.Map) map[string]string { attrs := make(map[string]string) rAttrs.Range(func(k string, v pcommon.Value) bool { - attrs[k] = v.AsString() + if v.Type() == pcommon.ValueTypeStr { + attrs[k] = v.AsString() + } + if v.Type() == pcommon.ValueTypeMap { + v.Map().Range(func(k2 string, v2 pcommon.Value) bool { + if v2.Type() == pcommon.ValueTypeStr { + attrs[k+"."+k2] = v2.AsString() + } + return true + }) + } return true }) return attrs @@ -347,6 +357,9 @@ func buildPath(name string, attributes pcommon.Map) string { buf.WriteString(name) attributes.Range(func(k string, v pcommon.Value) bool { + if v.Type() != pcommon.ValueTypeStr { + return true + } value := v.AsString() if value == "" { value = tagValueEmptyPlaceholder