@@ -80,6 +80,11 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
8080 }
8181 }
8282
83+ fn record_bytes ( & mut self , field : & tracing_core:: Field , value : & [ u8 ] ) {
84+ self . log_record
85+ . add_attribute ( Key :: new ( field. name ( ) ) , AnyValue :: from ( value) ) ;
86+ }
87+
8388 fn record_str ( & mut self , field : & tracing_core:: Field , value : & str ) {
8489 #[ cfg( feature = "experimental_metadata_attributes" ) ]
8590 if is_duplicated_metadata ( field. name ( ) ) {
@@ -350,7 +355,7 @@ mod tests {
350355 let big_u64value: u64 = u64:: MAX ;
351356 let small_usizevalue: usize = 42 ;
352357 let big_usizevalue: usize = usize:: MAX ;
353- error ! ( name
: "my-event-name" , target
: "my-system" , event_id =
20 , small_u64value
, big_u64value
, small_usizevalue
, big_usizevalue
, user_name =
"otel" , user_email =
"[email protected] " ) ; 358+ error ! ( name
: "my-event-name" , target
: "my-system" , event_id =
20 , bytes = & b"abc" [ .. ] , small_u64value
, big_u64value
, small_usizevalue
, big_usizevalue
, user_name =
"otel" , user_email =
"[email protected] " ) ; 354359 assert ! ( logger_provider. force_flush( ) . is_ok( ) ) ;
355360
356361 // Assert TODO: move to helper methods
@@ -381,9 +386,9 @@ mod tests {
381386
382387 // Validate attributes
383388 #[ cfg( not( feature = "experimental_metadata_attributes" ) ) ]
384- assert_eq ! ( log. record. attributes_iter( ) . count( ) , 7 ) ;
389+ assert_eq ! ( log. record. attributes_iter( ) . count( ) , 8 ) ;
385390 #[ cfg( feature = "experimental_metadata_attributes" ) ]
386- assert_eq ! ( log. record. attributes_iter( ) . count( ) , 11 ) ;
391+ assert_eq ! ( log. record. attributes_iter( ) . count( ) , 12 ) ;
387392 assert ! ( attributes_contains(
388393 & log. record,
389394 & Key :: new( "event_id" ) ,
@@ -419,6 +424,11 @@ mod tests {
419424 & Key :: new( "big_usizevalue" ) ,
420425 & AnyValue :: String ( format!( "{}" , u64 :: MAX ) . into( ) )
421426 ) ) ;
427+ assert ! ( attributes_contains(
428+ & log. record,
429+ & Key :: new( "bytes" ) ,
430+ & AnyValue :: Bytes ( Box :: new( b"abc" . to_vec( ) ) )
431+ ) ) ;
422432 #[ cfg( feature = "experimental_metadata_attributes" ) ]
423433 {
424434 assert ! ( attributes_contains(
0 commit comments