@@ -254,15 +254,11 @@ impl TraceExporter {
254
254
255
255
/// Send msgpack serialized traces to the agent
256
256
#[ allow( missing_docs) ]
257
- pub fn send ( & self , data : & [ u8 ] , trace_count : usize ) -> Result < String , String > {
257
+ pub fn send ( & self , data : tinybytes :: Bytes , trace_count : usize ) -> Result < String , String > {
258
258
self . check_agent_info ( ) ;
259
259
match self . input_format {
260
- TraceExporterInputFormat :: Proxy => self . send_proxy ( data, trace_count) ,
261
- TraceExporterInputFormat :: V04 => {
262
- self . send_deser_ser ( tinybytes:: Bytes :: copy_from_slice ( data) )
263
- // TODO: APMSP-1582 - Refactor data-pipeline-ffi so we can leverage a type that
264
- // implements tinybytes::UnderlyingBytes trait to avoid copying
265
- }
260
+ TraceExporterInputFormat :: Proxy => self . send_proxy ( data. as_ref ( ) , trace_count) ,
261
+ TraceExporterInputFormat :: V04 => self . send_deser_ser ( data) ,
266
262
}
267
263
}
268
264
@@ -1188,7 +1184,7 @@ mod tests {
1188
1184
..Default :: default ( )
1189
1185
} ] ;
1190
1186
1191
- let data = rmp_serde:: to_vec_named ( & vec ! [ trace_chunk] ) . unwrap ( ) ;
1187
+ let data = tinybytes :: Bytes :: from ( rmp_serde:: to_vec_named ( & vec ! [ trace_chunk] ) . unwrap ( ) ) ;
1192
1188
1193
1189
// Wait for the info fetcher to get the config
1194
1190
while mock_info. hits ( ) == 0 {
@@ -1197,7 +1193,7 @@ mod tests {
1197
1193
} )
1198
1194
}
1199
1195
1200
- exporter. send ( data. as_slice ( ) , 1 ) . unwrap ( ) ;
1196
+ exporter. send ( data, 1 ) . unwrap ( ) ;
1201
1197
exporter. shutdown ( None ) . unwrap ( ) ;
1202
1198
1203
1199
mock_traces. assert ( ) ;
@@ -1315,8 +1311,10 @@ mod tests {
1315
1311
..Default :: default ( )
1316
1312
} ] ,
1317
1313
] ;
1318
- let bytes = rmp_serde:: to_vec_named ( & traces) . expect ( "failed to serialize static trace" ) ;
1319
- let _result = exporter. send ( & bytes, 1 ) . expect ( "failed to send trace" ) ;
1314
+ let bytes = tinybytes:: Bytes :: from (
1315
+ rmp_serde:: to_vec_named ( & traces) . expect ( "failed to serialize static trace" ) ,
1316
+ ) ;
1317
+ let _result = exporter. send ( bytes, 1 ) . expect ( "failed to send trace" ) ;
1320
1318
1321
1319
assert_eq ! (
1322
1320
& format!(
@@ -1347,9 +1345,8 @@ mod tests {
1347
1345
stats_socket. local_addr ( ) . unwrap ( ) . to_string ( ) ,
1348
1346
) ;
1349
1347
1350
- let _result = exporter
1351
- . send ( b"some_bad_payload" , 1 )
1352
- . expect ( "failed to send trace" ) ;
1348
+ let bad_payload = tinybytes:: Bytes :: copy_from_slice ( b"some_bad_payload" . as_ref ( ) ) ;
1349
+ let _result = exporter. send ( bad_payload, 1 ) . expect ( "failed to send trace" ) ;
1353
1350
1354
1351
assert_eq ! (
1355
1352
& format!(
@@ -1382,8 +1379,10 @@ mod tests {
1382
1379
name: BytesString :: from_slice( b"test" ) . unwrap( ) ,
1383
1380
..Default :: default ( )
1384
1381
} ] ] ;
1385
- let bytes = rmp_serde:: to_vec_named ( & traces) . expect ( "failed to serialize static trace" ) ;
1386
- let _result = exporter. send ( & bytes, 1 ) . expect ( "failed to send trace" ) ;
1382
+ let bytes = tinybytes:: Bytes :: from (
1383
+ rmp_serde:: to_vec_named ( & traces) . expect ( "failed to serialize static trace" ) ,
1384
+ ) ;
1385
+ let _result = exporter. send ( bytes, 1 ) . expect ( "failed to send trace" ) ;
1387
1386
1388
1387
assert_eq ! (
1389
1388
& format!(
0 commit comments