1010import com .google .common .collect .ImmutableMap ;
1111import io .opentelemetry .api .common .AttributeKey ;
1212import io .opentelemetry .api .common .Attributes ;
13+ import io .opentelemetry .api .common .Value ;
1314import java .util .Arrays ;
1415import java .util .Collections ;
1516import java .util .HashMap ;
@@ -246,6 +247,27 @@ private static Stream<Arguments> attributesArgs() {
246247 .put (ExtendedAttributeKey .doubleArrayKey ("key" ), Arrays .asList (1.1 , 2.2 ))
247248 .build (),
248249 ImmutableMap .builder ().put ("key" , Arrays .asList (1.1 , 2.2 )).build ()),
250+ Arguments .of (
251+ ExtendedAttributes .builder ().put ("key" , new byte [] {1 , 2 }).build (),
252+ ImmutableMap .builder ().put ("key" , new byte [] {1 , 2 }).build ()),
253+ Arguments .of (
254+ ExtendedAttributes .builder ()
255+ .put (
256+ ExtendedAttributeKey .fromAttributeKey (AttributeKey .valueArrayKey ("key" )),
257+ Arrays .asList (Value .of ("one" ), Value .of (2L )))
258+ .build (),
259+ ImmutableMap .builder ()
260+ .put ("key" , Arrays .asList (Value .of ("one" ), Value .of (2L )))
261+ .build ()),
262+ Arguments .of (
263+ ExtendedAttributes .builder ()
264+ .put (
265+ ExtendedAttributeKey .fromAttributeKey (AttributeKey .mapKey ("key" )),
266+ Attributes .builder ().put ("child" , "value" ).build ())
267+ .build (),
268+ ImmutableMap .builder ()
269+ .put ("key" , Attributes .builder ().put ("child" , "value" ).build ())
270+ .build ()),
249271 Arguments .of (
250272 ExtendedAttributes .builder ()
251273 .put (
@@ -314,6 +336,12 @@ private static ExtendedAttributeKey<?> getKey(String key, Object value) {
314336 return ExtendedAttributeKey .longArrayKey (key );
315337 case DOUBLE_ARRAY :
316338 return ExtendedAttributeKey .doubleArrayKey (key );
339+ case BYTE_ARRAY :
340+ return ExtendedAttributeKey .fromAttributeKey (AttributeKey .byteArrayKey (key ));
341+ case VALUE_ARRAY :
342+ return ExtendedAttributeKey .fromAttributeKey (AttributeKey .valueArrayKey (key ));
343+ case MAP :
344+ return ExtendedAttributeKey .fromAttributeKey (AttributeKey .mapKey (key ));
317345 case EXTENDED_ATTRIBUTES :
318346 return ExtendedAttributeKey .extendedAttributesKey (key );
319347 }
@@ -334,11 +362,17 @@ private static ExtendedAttributeType getType(Object value) {
334362 if ((value instanceof Double ) || (value instanceof Float )) {
335363 return ExtendedAttributeType .DOUBLE ;
336364 }
365+ if (value instanceof byte []) {
366+ return ExtendedAttributeType .BYTE_ARRAY ;
367+ }
337368 if (value instanceof List ) {
338369 List <Object > list = (List <Object >) value ;
339370 if (list .isEmpty ()) {
340371 throw new IllegalArgumentException ("Empty list" );
341372 }
373+ if (list .get (0 ) instanceof Value ) {
374+ return ExtendedAttributeType .VALUE_ARRAY ;
375+ }
342376 if (list .get (0 ) instanceof String ) {
343377 return ExtendedAttributeType .STRING_ARRAY ;
344378 }
@@ -352,6 +386,9 @@ private static ExtendedAttributeType getType(Object value) {
352386 return ExtendedAttributeType .DOUBLE_ARRAY ;
353387 }
354388 }
389+ if (value instanceof Attributes ) {
390+ return ExtendedAttributeType .MAP ;
391+ }
355392 if ((value instanceof Map )) {
356393 return ExtendedAttributeType .EXTENDED_ATTRIBUTES ;
357394 }
0 commit comments