@@ -265,6 +265,7 @@ struct aws_s3_mmap_part_streaming_input_stream_impl {
265265 struct s3_data_read_metrics metrics ;
266266
267267 struct aws_s3_meta_request * meta_request ;
268+ struct aws_s3_request * request ;
268269};
269270
270271static int s_aws_s3_mmap_part_streaming_input_stream_seek (
@@ -282,6 +283,11 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
282283 AWS_CONTAINER_OF (stream , struct aws_s3_mmap_part_streaming_input_stream_impl , base );
283284 /* Map the content */
284285 size_t read_length = aws_min_size (dest -> capacity - dest -> len , impl -> total_length - impl -> total_length_read );
286+ uint64_t time = 0 ;
287+ if (impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns == -1 ) {
288+ aws_high_res_clock_get_ticks (& time );
289+ impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns = time ;
290+ }
285291 aws_high_res_clock_get_ticks (& impl -> metrics .start_timestamp );
286292 impl -> metrics .thread_id = aws_thread_current_thread_id ();
287293
@@ -326,6 +332,12 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
326332 impl -> in_chunk_offset += read_length ;
327333 impl -> total_length_read += read_length ;
328334 aws_high_res_clock_get_ticks (& impl -> metrics .end_timestamp );
335+ int64_t duration = impl -> metrics .end_timestamp - impl -> metrics .start_timestamp ;
336+ if (impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns == -1 ) {
337+ impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns = duration ;
338+ } else {
339+ impl -> request -> send_data .metrics -> time_metrics .body_read_total_ns += duration ;
340+ }
329341
330342 /* BEGIN CRITICAL SECTION */
331343 aws_s3_meta_request_lock_synced_data (impl -> meta_request );
@@ -340,6 +352,13 @@ static int s_aws_s3_mmap_part_streaming_input_stream_read(struct aws_input_strea
340352 /* We reached the end of the stream. */
341353 impl -> eos_reached = true;
342354 AWS_ASSERT (impl -> total_length_read == impl -> total_length );
355+ if (impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns == -1 ) {
356+ aws_high_res_clock_get_ticks (& time );
357+ impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns = time ;
358+ }
359+ impl -> request -> send_data .metrics -> time_metrics .body_read_duration_ns =
360+ impl -> request -> send_data .metrics -> time_metrics .body_read_end_timestamp_ns -
361+ impl -> request -> send_data .metrics -> time_metrics .body_read_start_timestamp_ns ;
343362 }
344363 }
345364
@@ -409,6 +428,7 @@ struct aws_input_stream *aws_input_stream_new_from_parallel_stream(
409428 struct aws_allocator * allocator ,
410429 struct aws_parallel_input_stream * stream ,
411430 struct aws_s3_meta_request * meta_request ,
431+ struct aws_s3_request * request ,
412432 uint64_t offset ,
413433 size_t request_body_size ) {
414434
@@ -431,6 +451,7 @@ struct aws_input_stream *aws_input_stream_new_from_parallel_stream(
431451 impl -> loading_chunk_buf = & impl -> chunk_buf_1 ;
432452 impl -> reading_chunk_buf = & impl -> chunk_buf_2 ;
433453 impl -> meta_request = meta_request ;
454+ impl -> request = request ;
434455
435456 /* Reset the input stream to start */
436457 aws_streaming_input_stream_reset (& impl -> base );
0 commit comments