@@ -88,7 +88,7 @@ impl OtlpEncoder {
8888 }
8989 }
9090
91- let mut batches: HashMap < String , BatchData > = HashMap :: new ( ) ;
91+ let mut batches: HashMap < & str , BatchData > = HashMap :: new ( ) ;
9292
9393 for log_record in logs {
9494 // Get the timestamp - prefer time_unix_nano, fall back to observed_time_unix_nano if time_unix_nano is 0
@@ -114,17 +114,15 @@ impl OtlpEncoder {
114114 let level = log_record. severity_number as u8 ;
115115
116116 // 3. Create or get existing batch entry with metadata tracking
117- let entry = batches
118- . entry ( event_name_str. to_string ( ) )
119- . or_insert_with ( || BatchData {
120- schemas : Vec :: new ( ) ,
121- events : Vec :: new ( ) ,
122- metadata : BatchMetadata {
123- start_time : timestamp,
124- end_time : timestamp,
125- schema_ids : String :: new ( ) ,
126- } ,
127- } ) ;
117+ let entry = batches. entry ( event_name_str) . or_insert_with ( || BatchData {
118+ schemas : Vec :: new ( ) ,
119+ events : Vec :: new ( ) ,
120+ metadata : BatchMetadata {
121+ start_time : timestamp,
122+ end_time : timestamp,
123+ schema_ids : String :: new ( ) ,
124+ } ,
125+ } ) ;
128126
129127 // Update timestamp range
130128 if timestamp != 0 {
@@ -165,7 +163,7 @@ impl OtlpEncoder {
165163 let compressed = lz4_chunked_compression ( & uncompressed)
166164 . map_err ( |e| format ! ( "compression failed: {e}" ) ) ?;
167165 blobs. push ( EncodedBatch {
168- event_name : batch_event_name,
166+ event_name : batch_event_name. to_string ( ) ,
169167 data : compressed,
170168 metadata : batch_data. metadata ,
171169 } ) ;
@@ -558,12 +556,10 @@ impl OtlpEncoder {
558556 }
559557 _ => {
560558 // Handle dynamic attributes
561- let attr = span
562- . attributes
563- . iter ( )
564- . find ( |a| a. key == field. name )
565- . unwrap ( ) ;
566- self . write_attribute_value ( & mut buffer, attr, field. type_id ) ;
559+ // TODO - optimize better - we could update determine_fields to also return a vec of bytes which has bond serialized attributes
560+ if let Some ( attr) = span. attributes . iter ( ) . find ( |a| a. key == field. name ) {
561+ self . write_attribute_value ( & mut buffer, attr, field. type_id ) ;
562+ }
567563 }
568564 }
569565 }
0 commit comments