diff --git a/config/configparser/parser.go b/config/configparser/parser.go index c39c345c668..ad086b26f01 100644 --- a/config/configparser/parser.go +++ b/config/configparser/parser.go @@ -187,7 +187,7 @@ func decoderConfig(result interface{}) *mapstructure.DecoderConfig { // config: // thing: // -// we want an unmarshalled Config to be equivalent to +// we want an unmarshaled Config to be equivalent to // Config{Thing: &SomeStruct{}} instead of Config{Thing: nil} func expandNilStructPointers() mapstructure.DecodeHookFunc { return func(from reflect.Value, to reflect.Value) (interface{}, error) { diff --git a/config/configunmarshaler/defaultunmarshaler.go b/config/configunmarshaler/defaultunmarshaler.go index 4b5bbc86b40..953b670891f 100644 --- a/config/configunmarshaler/defaultunmarshaler.go +++ b/config/configunmarshaler/defaultunmarshaler.go @@ -96,7 +96,7 @@ func NewDefault() ConfigUnmarshaler { } // Unmarshal the Config from a Parser. -// After the config is unmarshalled, `Validate()` must be called to validate. +// After the config is unmarshaled, `Validate()` must be called to validate. func (*defaultUnmarshaler) Unmarshal(v *configparser.ConfigMap, factories component.Factories) (*config.Config, error) { var cfg config.Config diff --git a/model/pdata/common.go b/model/pdata/common.go index 1ee9212211d..76bbfc0965e 100644 --- a/model/pdata/common.go +++ b/model/pdata/common.go @@ -384,7 +384,7 @@ func (a AttributeValue) AsString() string { return strconv.FormatInt(a.IntVal(), 10) case AttributeValueTypeMap: - jsonStr, _ := json.Marshal(AttributeMapToMap(a.MapVal())) + jsonStr, _ := json.Marshal(a.MapVal().AsRaw()) return string(jsonStr) case AttributeValueTypeArray: @@ -795,10 +795,10 @@ func (am AttributeMap) CopyTo(dest AttributeMap) { *dest.orig = origs } -// AttributeMapToMap converts an OTLP AttributeMap to a standard go map -func AttributeMapToMap(attrMap AttributeMap) map[string]interface{} { +// AsRaw converts an OTLP AttributeMap to a standard go map +func (am AttributeMap) AsRaw() map[string]interface{} { rawMap := make(map[string]interface{}) - attrMap.Range(func(k string, v AttributeValue) bool { + am.Range(func(k string, v AttributeValue) bool { switch v.Type() { case AttributeValueTypeString: rawMap[k] = v.StringVal() @@ -811,7 +811,7 @@ func AttributeMapToMap(attrMap AttributeMap) map[string]interface{} { case AttributeValueTypeNull: rawMap[k] = nil case AttributeValueTypeMap: - rawMap[k] = AttributeMapToMap(v.MapVal()) + rawMap[k] = v.MapVal().AsRaw() case AttributeValueTypeArray: rawMap[k] = attributeArrayToSlice(v.ArrayVal()) } @@ -820,6 +820,12 @@ func AttributeMapToMap(attrMap AttributeMap) map[string]interface{} { return rawMap } +// AttributeMapToMap converts an OTLP AttributeMap to a standard go map +// Deprecated: use AttributeMap's AsRaw method instead. +func AttributeMapToMap(attrMap AttributeMap) map[string]interface{} { + return attrMap.AsRaw() +} + // attributeArrayToSlice creates a slice out of a AnyValueArray. func attributeArrayToSlice(attrArray AnyValueArray) []interface{} { rawSlice := make([]interface{}, 0, attrArray.Len())