Skip to content

Commit

Permalink
Use the slice type in the attribute map when mapping user properties
Browse files Browse the repository at this point in the history
OpenTelemetry+backends do not support the Bytes type, and instead support a slice of integers

SOL-78624
  • Loading branch information
mcardy committed Sep 28, 2022
1 parent 4715c43 commit 48b9730
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion receiver/solacereceiver/unmarshaller.go
Original file line number Diff line number Diff line change
Expand Up @@ -455,7 +455,11 @@ func (u *solaceMessageUnmarshallerV1) insertUserProperty(toMap pcommon.Map, key
case *model_v1.SpanData_UserPropertyValue_DoubleValue:
toMap.PutDouble(k, v.DoubleValue)
case *model_v1.SpanData_UserPropertyValue_ByteArrayValue:
toMap.PutEmptyBytes(k).FromRaw(v.ByteArrayValue)
// Convert the byte array to a slice of integers
slice := toMap.PutEmptySlice(k)
for _, b := range v.ByteArrayValue {
slice.AppendEmpty().SetIntVal((int64)(b))
}
case *model_v1.SpanData_UserPropertyValue_FloatValue:
toMap.PutDouble(k, float64(v.FloatValue))
case *model_v1.SpanData_UserPropertyValue_Int8Value:
Expand Down
4 changes: 2 additions & 2 deletions receiver/solacereceiver/unmarshaller_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -962,9 +962,9 @@ func TestUnmarshallerInsertUserProperty(t *testing.T) {
},
{
&model_v1.SpanData_UserPropertyValue_ByteArrayValue{ByteArrayValue: []byte{1, 2, 3, 4}},
pcommon.ValueTypeBytes,
pcommon.ValueTypeSlice,
func(val pcommon.Value) {
assert.Equal(t, []byte{1, 2, 3, 4}, val.BytesVal().AsRaw())
assert.Equal(t, []interface{}{int64(1), int64(2), int64(3), int64(4)}, val.SliceVal().AsRaw())
},
},
{
Expand Down

0 comments on commit 48b9730

Please sign in to comment.