From d582399072dd4d773393ae1c96f688c91fde89f5 Mon Sep 17 00:00:00 2001 From: Vishal Sharma Date: Tue, 13 Sep 2022 21:56:54 +0530 Subject: [PATCH] feat: support all types of attributes (#14) * feat: support all types of attributes * feat: handle all tag types for resource attributes --- .../clickhouse_exporter.go | 20 +++---------------- 1 file changed, 3 insertions(+), 17 deletions(-) diff --git a/exporter/clickhousetracesexporter/clickhouse_exporter.go b/exporter/clickhousetracesexporter/clickhouse_exporter.go index 6fb27969..90e6d86a 100644 --- a/exporter/clickhousetracesexporter/clickhouse_exporter.go +++ b/exporter/clickhousetracesexporter/clickhouse_exporter.go @@ -196,11 +196,7 @@ func populateEvents(events ptrace.SpanEventSlice, span *Span) { event.AttributeMap = map[string]string{} event.IsError = false events.At(i).Attributes().Range(func(k string, v pcommon.Value) bool { - if v.Type().String() == "INT" { - event.AttributeMap[k] = strconv.FormatInt(v.IntVal(), 10) - } else { - event.AttributeMap[k] = v.StringVal() - } + event.AttributeMap[k] = v.AsString() return true }) if event.Name == "exception" { @@ -231,23 +227,13 @@ func newStructuredSpan(otelSpan ptrace.Span, ServiceName string, resource pcommo tagMap := map[string]string{} attributes.Range(func(k string, v pcommon.Value) bool { - v.StringVal() - if v.Type().String() == "INT" { - tagMap[k] = strconv.FormatInt(v.IntVal(), 10) - } else if v.StringVal() != "" { - tagMap[k] = v.StringVal() - } + tagMap[k] = v.AsString() return true }) resourceAttributes.Range(func(k string, v pcommon.Value) bool { - v.StringVal() - if v.Type().String() == "INT" { - tagMap[k] = strconv.FormatInt(v.IntVal(), 10) - } else if v.StringVal() != "" { - tagMap[k] = v.StringVal() - } + tagMap[k] = v.AsString() return true })