@@ -11,6 +11,7 @@ import (
1111 "github.com/stretchr/testify/require"
1212 "go.opentelemetry.io/collector/pdata/pcommon"
1313 "go.opentelemetry.io/collector/pdata/ptrace"
14+ "go.opentelemetry.io/collector/pdata/xpdata"
1415
1516 "github.com/jaegertracing/jaeger/internal/telemetry/otelsemconv"
1617)
@@ -32,7 +33,7 @@ func TestRoundTrip(t *testing.T) {
3233 })
3334
3435 t .Run ("FromRow->ToRow" , func (t * testing.T ) {
35- spanRow := createTestSpanRow (now , duration )
36+ spanRow := createTestSpanRow (t , now , duration )
3637
3738 trace := FromRow (spanRow )
3839 rs := trace .ResourceSpans ().At (0 ).Resource ()
@@ -114,10 +115,30 @@ func addTestAttributes(attrs pcommon.Map) {
114115 attrs .PutInt ("int_attr" , 42 )
115116 attrs .PutStr ("string_attr" , "string_value" )
116117 attrs .PutEmptyBytes ("bytes_attr" ).FromRaw ([]byte ("bytes_value" ))
118+ attrs .PutEmptyMap ("map_attr" ).FromRaw (map [string ]any {"key" : "value" })
119+ attrs .PutEmptySlice ("slice_attr" ).FromRaw ([]any {1 , 2 , 3 })
117120}
118121
119- func createTestSpanRow (now time.Time , duration time.Duration ) * SpanRow {
122+ func createTestSpanRow (t * testing.T , now time.Time , duration time.Duration ) * SpanRow {
123+ t .Helper ()
120124 encodedBytes := base64 .StdEncoding .EncodeToString ([]byte ("bytes_value" ))
125+
126+ vm := pcommon .NewValueMap ()
127+ vm .Map ().PutStr ("key" , "value" )
128+ m := & xpdata.JSONMarshaler {}
129+ buf , err := m .MarshalValue (vm )
130+ require .NoError (t , err )
131+ encodedMap := base64 .StdEncoding .EncodeToString (buf )
132+
133+ vs := pcommon .NewValueSlice ()
134+ vs .Slice ().AppendEmpty ().SetInt (1 )
135+ vs .Slice ().AppendEmpty ().SetInt (2 )
136+ vs .Slice ().AppendEmpty ().SetInt (3 )
137+ mSlice := & xpdata.JSONMarshaler {}
138+ buf , err = mSlice .MarshalValue (vs )
139+ require .NoError (t , err )
140+ encodedSlice := base64 .StdEncoding .EncodeToString (buf )
141+
121142 return & SpanRow {
122143 ID : "0000000000000001" ,
123144 TraceID : "00000000000000000000000000000001" ,
@@ -138,8 +159,8 @@ func createTestSpanRow(now time.Time, duration time.Duration) *SpanRow {
138159 IntValues : []int64 {42 },
139160 StrKeys : []string {"string_attr" },
140161 StrValues : []string {"string_value" },
141- ComplexKeys : []string {"@bytes@bytes_attr" },
142- ComplexValues : []string {encodedBytes },
162+ ComplexKeys : []string {"@bytes@bytes_attr" , "@map@map_attr" , "@slice@slice_attr" },
163+ ComplexValues : []string {encodedBytes , encodedMap , encodedSlice },
143164 },
144165 EventNames : []string {"test-event" },
145166 EventTimestamps : []time.Time {now },
@@ -152,8 +173,8 @@ func createTestSpanRow(now time.Time, duration time.Duration) *SpanRow {
152173 IntValues : [][]int64 {{42 }},
153174 StrKeys : [][]string {{"string_attr" }},
154175 StrValues : [][]string {{"string_value" }},
155- ComplexKeys : [][]string {{"@bytes@bytes_attr" }},
156- ComplexValues : [][]string {{encodedBytes }},
176+ ComplexKeys : [][]string {{"@bytes@bytes_attr" , "@map@map_attr" , "@slice@slice_attr" }},
177+ ComplexValues : [][]string {{encodedBytes , encodedMap , encodedSlice }},
157178 },
158179 LinkTraceIDs : []string {"00000000000000000000000000000003" },
159180 LinkSpanIDs : []string {"0000000000000004" },
@@ -167,8 +188,8 @@ func createTestSpanRow(now time.Time, duration time.Duration) *SpanRow {
167188 IntValues : [][]int64 {{42 }},
168189 StrKeys : [][]string {{"string_attr" }},
169190 StrValues : [][]string {{"string_value" }},
170- ComplexKeys : [][]string {{"@bytes@bytes_attr" }},
171- ComplexValues : [][]string {{encodedBytes }},
191+ ComplexKeys : [][]string {{"@bytes@bytes_attr" , "@map@map_attr" , "@slice@slice_attr" }},
192+ ComplexValues : [][]string {{encodedBytes , encodedMap , encodedSlice }},
172193 },
173194 ServiceName : "test-service" ,
174195 ResourceAttributes : Attributes {
@@ -180,8 +201,8 @@ func createTestSpanRow(now time.Time, duration time.Duration) *SpanRow {
180201 IntValues : []int64 {42 },
181202 StrKeys : []string {"service.name" , "string_attr" },
182203 StrValues : []string {"test-service" , "string_value" },
183- ComplexKeys : []string {"@bytes@bytes_attr" },
184- ComplexValues : []string {encodedBytes },
204+ ComplexKeys : []string {"@bytes@bytes_attr" , "@map@map_attr" , "@slice@slice_attr" },
205+ ComplexValues : []string {encodedBytes , encodedMap , encodedSlice },
185206 },
186207 ScopeName : "test-scope" ,
187208 ScopeVersion : "v1.0.0" ,
@@ -194,8 +215,8 @@ func createTestSpanRow(now time.Time, duration time.Duration) *SpanRow {
194215 IntValues : []int64 {42 },
195216 StrKeys : []string {"string_attr" },
196217 StrValues : []string {"string_value" },
197- ComplexKeys : []string {"@bytes@bytes_attr" },
198- ComplexValues : []string {encodedBytes },
218+ ComplexKeys : []string {"@bytes@bytes_attr" , "@map@map_attr" , "@slice@slice_attr" },
219+ ComplexValues : []string {encodedBytes , encodedMap , encodedSlice },
199220 },
200221 }
201222}
0 commit comments