in exporter/collector/spandata.go [133:161]
func pdataAttributesToOTAttributes(attrs pcommon.Map, resource pcommon.Resource) []attribute.KeyValue {
otAttrs := make([]attribute.KeyValue, 0, attrs.Len())
appendAttrs := func(m pcommon.Map) {
m.Range(func(k string, v pcommon.Value) bool {
if (k == semconv.AttributeServiceName ||
k == semconv.AttributeServiceNamespace ||
k == semconv.AttributeServiceInstanceID) &&
len(v.AsString()) == 0 {
return true
}
switch v.Type() {
case pcommon.ValueTypeStr:
otAttrs = append(otAttrs, attribute.String(k, v.Str()))
case pcommon.ValueTypeBool:
otAttrs = append(otAttrs, attribute.Bool(k, v.Bool()))
case pcommon.ValueTypeInt:
otAttrs = append(otAttrs, attribute.Int64(k, v.Int()))
case pcommon.ValueTypeDouble:
otAttrs = append(otAttrs, attribute.Float64(k, v.Double()))
default:
otAttrs = append(otAttrs, attribute.String(k, v.AsString()))
}
return true
})
}
appendAttrs(resource.Attributes())
appendAttrs(attrs)
return otAttrs
}