@@ -1208,7 +1208,7 @@ pub async fn root_search(
1208
1208
let current_span = tracing:: Span :: current ( ) ;
1209
1209
current_span. record ( "num_docs" , num_docs) ;
1210
1210
current_span. record ( "num_splits" , num_splits) ;
1211
- target_split_sender. send ( 0 ) . ok ( ) ;
1211
+ target_split_sender. send ( num_splits ) . ok ( ) ;
1212
1212
1213
1213
let mut search_response_result = root_search_aux (
1214
1214
searcher_context,
@@ -1765,21 +1765,19 @@ pub fn jobs_to_fetch_docs_requests(
1765
1765
async fn start_root_search_metric_recording (
1766
1766
start_instant : tokio:: time:: Instant ,
1767
1767
) -> ( oneshot:: Sender < bool > , oneshot:: Sender < usize > ) {
1768
- let ( completion_tx, completion_rx) = tokio :: sync :: oneshot:: channel ( ) ;
1769
- let ( target_split_tx, target_split_rx) = tokio :: sync :: oneshot:: channel ( ) ;
1768
+ let ( completion_tx, completion_rx) = oneshot:: channel ( ) ;
1769
+ let ( target_split_tx, target_split_rx) = oneshot:: channel ( ) ;
1770
1770
tokio:: spawn ( async move {
1771
1771
let ( completion_res, target_split_res) = tokio:: join!( completion_rx, target_split_rx) ;
1772
- let label_values = if let Ok ( is_success) = completion_res {
1773
- if is_success {
1774
- [ "success" ]
1775
- } else {
1776
- [ "error" ]
1777
- }
1778
- } else {
1779
- [ "cancelled" ]
1780
- } ;
1781
1772
1782
- let num_splits = target_split_res. unwrap_or ( 0 ) ;
1773
+ let ( label_values, num_splits) = match ( completion_res, target_split_res) {
1774
+ ( Ok ( true ) , Ok ( num_splits) ) => ( [ "success" ] , num_splits) ,
1775
+ ( Ok ( false ) , Ok ( num_splits) ) => ( [ "error" ] , num_splits) ,
1776
+ ( Err ( _) , Ok ( num_splits) ) => ( [ "cancelled" ] , num_splits) ,
1777
+ ( Err ( _) , Err ( _) ) => ( [ "planning-failed" ] , 0 ) ,
1778
+ // Should not happen, num split is resolved before the query
1779
+ ( Ok ( _) , Err ( _) ) => ( [ "unexpected" ] , 0 ) ,
1780
+ } ;
1783
1781
1784
1782
SEARCH_METRICS
1785
1783
. root_search_requests_total
0 commit comments