@@ -80,6 +80,11 @@ impl<LR: LogRecord> tracing::field::Visit for EventVisitor<'_, LR> {
80
80
}
81
81
}
82
82
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
+
83
88
fn record_str ( & mut self , field : & tracing_core:: Field , value : & str ) {
84
89
#[ cfg( feature = "experimental_metadata_attributes" ) ]
85
90
if is_duplicated_metadata ( field. name ( ) ) {
@@ -350,7 +355,7 @@ mod tests {
350
355
let big_u64value: u64 = u64:: MAX ;
351
356
let small_usizevalue: usize = 42 ;
352
357
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 = "otel@opentelemetry.io" ) ;
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 = "otel@opentelemetry.io" ) ;
354
359
assert ! ( logger_provider. force_flush( ) . is_ok( ) ) ;
355
360
356
361
// Assert TODO: move to helper methods
@@ -381,9 +386,9 @@ mod tests {
381
386
382
387
// Validate attributes
383
388
#[ cfg( not( feature = "experimental_metadata_attributes" ) ) ]
384
- assert_eq ! ( log. record. attributes_iter( ) . count( ) , 7 ) ;
389
+ assert_eq ! ( log. record. attributes_iter( ) . count( ) , 8 ) ;
385
390
#[ cfg( feature = "experimental_metadata_attributes" ) ]
386
- assert_eq ! ( log. record. attributes_iter( ) . count( ) , 11 ) ;
391
+ assert_eq ! ( log. record. attributes_iter( ) . count( ) , 12 ) ;
387
392
assert ! ( attributes_contains(
388
393
& log. record,
389
394
& Key :: new( "event_id" ) ,
@@ -419,6 +424,11 @@ mod tests {
419
424
& Key :: new( "big_usizevalue" ) ,
420
425
& AnyValue :: String ( format!( "{}" , u64 :: MAX ) . into( ) )
421
426
) ) ;
427
+ assert ! ( attributes_contains(
428
+ & log. record,
429
+ & Key :: new( "bytes" ) ,
430
+ & AnyValue :: Bytes ( Box :: new( b"abc" . to_vec( ) ) )
431
+ ) ) ;
422
432
#[ cfg( feature = "experimental_metadata_attributes" ) ]
423
433
{
424
434
assert ! ( attributes_contains(
0 commit comments