peterxcli opened a new pull request, #19127:
URL: https://github.com/apache/datafusion/pull/19127

   ## Which issue does this PR close?
   
   <!--
   We generally require a GitHub issue to be filed for all bug fixes and 
enhancements and this helps us generate change logs for our releases. You can 
link an issue to this PR using the GitHub syntax. For example `Closes #123` 
indicates that this PR will close issue #123.
   -->
   
   - Closes https://github.com/apache/datafusion/issues/18138
   
   ## Rationale for this change
   
   The `list` operation returns a stream, so it previously recorded `duration: 
None`, missing performance insights. Time-to-first-item is a useful metric for 
list operations, indicating how quickly results start. This adds duration 
tracking by measuring time until the first item is yielded (or the stream ends).
   
   ## What changes are included in this PR?
   
   1. Added `TimeToFirstItemStream`: A stream wrapper that measures elapsed 
time from creation until the first item is yielded (or the stream ends if 
empty).
   2. Updated `instrumented_list`: Wraps the inner stream with 
`TimeToFirstItemStream` to record duration.
   3. Changed `requests` field: Switched from `Mutex<Vec<RequestDetails>>` to 
`Arc<Mutex<Vec<RequestDetails>>>` to allow sharing across async boundaries 
(needed for the stream wrapper).
   4. Updated tests: Modified `instrumented_store_list` to consume at least one 
stream item and verify that `duration` is now `Some(Duration)` instead of 
`None`.
   
   ## Are these changes tested?
   
   Yes. The existing test `instrumented_store_list` was updated to:
   - Consume at least one item from the stream using `stream.next().await`
   - Assert that `request.duration.is_some()` (previously `is_none()`)
   
   All tests pass, including the updated list test and other instrumented 
operation tests.
   
   ## Are there any user-facing changes?
   
   Users with profiling enabled will see duration values for `list` operations 
instead of nothing.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to