Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions libbeat/otelbeat/otelmap/otelmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,15 @@ func ConvertNonPrimitive[T mapstrOrMap](m T) {
s := make([]any, ref.Len())
for i := 0; i < ref.Len(); i++ {
elem := ref.Index(i).Interface()
if m, ok := elem.(map[string]any); ok {
ConvertNonPrimitive(m)
if mi, ok := elem.(map[string]any); ok {
ConvertNonPrimitive(mi)
s[i] = mi
} else if mi, ok := elem.(mapstr.M); ok {
ConvertNonPrimitive(mi)
s[i] = map[string]any(mi)
} else {
s[i] = elem
}
s[i] = elem
}
m[key] = s
break // we figured out the type, so we don't need the unknown type case
Expand Down
4 changes: 3 additions & 1 deletion libbeat/otelbeat/otelmap/otelmap_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ func TestFromMapstrMapstr(t *testing.T) {
}

func TestFromMapstrSliceMapstr(t *testing.T) {
inputSlice := []mapstr.M{mapstr.M{"item": 1}, mapstr.M{"item": 1}, mapstr.M{"item": 1}}
inputSlice := []mapstr.M{{"item": 1}, {"item": 1}, {"item": 1}}
inputMap := mapstr.M{
"slice": inputSlice,
}
Expand Down Expand Up @@ -292,6 +292,7 @@ func TestFromMapstrWithNestedData(t *testing.T) {
"inner_int": 43,
"inner_map_slice": []any{
map[string]any{"string": "string3"},
mapstr.M{"number": 12.4},
},
"inner_slice": [2]map[string]any{ // array -> slice
{"string": "string2"},
Expand All @@ -318,6 +319,7 @@ func TestFromMapstrWithNestedData(t *testing.T) {
"inner_int": 43,
"inner_map_slice": []any{
map[string]any{"string": "string3"},
map[string]any{"number": 12.4},
},
"inner_slice": []any{
map[string]any{"string": "string2"},
Expand Down