@@ -261,9 +261,12 @@ def verify_span(d: Any) -> Span:
261261 ), f"Expected 'double_value' to be of type: 'float', got: { type (attr ['double_value' ])} "
262262 elif attr ["type" ] == 4 :
263263 assert isinstance (
264- attr ["array_value" ], list
265- ), f"Expected 'array_value' to be of type: 'list', got: { type (attr ['array_value' ])} "
266- array = attr ["array_value" ]
264+ attr ["array_value" ], dict
265+ ), f"Expected 'array_value' to be of type: 'dict', got: { type (attr ['array_value' ])} "
266+ assert (
267+ len (attr ["array_value" ]) == 1 and attr ["array_value" ].get ("values" ) is not None
268+ ), f"Expected 'array_value' to contain exactly one key values, got keys: { ' ,' .join (attr ['array_value' ].keys ())} "
269+ array = attr ["array_value" ]["values" ]
267270 if array :
268271 first_type = array [0 ]["type" ]
269272 i = None
@@ -433,10 +436,10 @@ def copy_span_events(s: SpanEvent) -> SpanEvent:
433436 # Copy arrays inside attributes
434437 for k , v in attributes .items ():
435438 if isinstance (v , dict ) and v ["type" ] == "array_value" :
436- array = v ["array_value" ]
439+ array = v ["array_value" ][ "values" ]
437440
438441 value = v .copy ()
439- value ["array_value" ] = array .copy ()
442+ value ["array_value" ] = { "values" : array .copy ()}
440443
441444 attributes [k ] = value
442445 copy ["attributes" ] = attributes
@@ -543,17 +546,17 @@ def add_span_event(
543546 elif isinstance (v , float ):
544547 new_attributes [k ] = {"type" : 3 , "double_value" : v }
545548 elif isinstance (v , list ):
546- array_value : List [Dict [str , Any ]] = []
549+ array_value : Dict [ str , List [Dict [str , Any ]]] = { "values" : []}
547550 new_attributes [k ] = {"type" : 4 , "array_value" : array_value }
548551 for i in v :
549552 if isinstance (i , str ):
550- array_value .append ({"type" : 0 , "string_value" : i })
553+ array_value [ "values" ] .append ({"type" : 0 , "string_value" : i })
551554 elif isinstance (i , bool ):
552- array_value .append ({"type" : 1 , "bool_value" : i })
555+ array_value [ "values" ] .append ({"type" : 1 , "bool_value" : i })
553556 elif isinstance (i , int ):
554- array_value .append ({"type" : 2 , "int_value" : i })
557+ array_value [ "values" ] .append ({"type" : 2 , "int_value" : i })
555558 elif isinstance (i , float ):
556- array_value .append ({"type" : 3 , "double_value" : i })
559+ array_value [ "values" ] .append ({"type" : 3 , "double_value" : i })
557560 else :
558561 raise ValueError (f"Unsupported span event attribute type { type (i )} for: { k } ={ v } " )
559562 else :
0 commit comments