@@ -88,7 +88,7 @@ impl OtlpEncoder {
88
88
}
89
89
}
90
90
91
- let mut batches: HashMap < String , BatchData > = HashMap :: new ( ) ;
91
+ let mut batches: HashMap < & str , BatchData > = HashMap :: new ( ) ;
92
92
93
93
for log_record in logs {
94
94
// 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 {
114
114
let level = log_record. severity_number as u8 ;
115
115
116
116
// 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
+ } ) ;
128
126
129
127
// Update timestamp range
130
128
if timestamp != 0 {
@@ -165,7 +163,7 @@ impl OtlpEncoder {
165
163
let compressed = lz4_chunked_compression ( & uncompressed)
166
164
. map_err ( |e| format ! ( "compression failed: {e}" ) ) ?;
167
165
blobs. push ( EncodedBatch {
168
- event_name : batch_event_name,
166
+ event_name : batch_event_name. to_string ( ) ,
169
167
data : compressed,
170
168
metadata : batch_data. metadata ,
171
169
} ) ;
@@ -558,12 +556,10 @@ impl OtlpEncoder {
558
556
}
559
557
_ => {
560
558
// 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
+ }
567
563
}
568
564
}
569
565
}
0 commit comments