@@ -1209,7 +1209,7 @@ pub async fn root_search(
12091209 let current_span = tracing:: Span :: current ( ) ;
12101210 current_span. record ( "num_docs" , num_docs) ;
12111211 current_span. record ( "num_splits" , num_splits) ;
1212- target_split_sender. send ( 0 ) . ok ( ) ;
1212+ target_split_sender. send ( num_splits ) . ok ( ) ;
12131213
12141214 let mut search_response_result = root_search_aux (
12151215 searcher_context,
@@ -1766,17 +1766,19 @@ pub fn jobs_to_fetch_docs_requests(
17661766async fn start_root_search_metric_recording (
17671767 start_instant : tokio:: time:: Instant ,
17681768) -> ( oneshot:: Sender < bool > , oneshot:: Sender < usize > ) {
1769- let ( completion_tx, completion_rx) = tokio :: sync :: oneshot:: channel ( ) ;
1770- let ( target_split_tx, target_split_rx) = tokio :: sync :: oneshot:: channel ( ) ;
1769+ let ( completion_tx, completion_rx) = oneshot:: channel ( ) ;
1770+ let ( target_split_tx, target_split_rx) = oneshot:: channel ( ) ;
17711771 tokio:: spawn ( async move {
17721772 let ( completion_res, target_split_res) = tokio:: join!( completion_rx, target_split_rx) ;
1773- let label_values = if let Ok ( is_success) = completion_res {
1774- if is_success { [ "success" ] } else { [ "error" ] }
1775- } else {
1776- [ "cancelled" ]
1777- } ;
17781773
1779- let num_splits = target_split_res. unwrap_or ( 0 ) ;
1774+ let ( label_values, num_splits) = match ( completion_res, target_split_res) {
1775+ ( Ok ( true ) , Ok ( num_splits) ) => ( [ "success" ] , num_splits) ,
1776+ ( Ok ( false ) , Ok ( num_splits) ) => ( [ "error" ] , num_splits) ,
1777+ ( Err ( _) , Ok ( num_splits) ) => ( [ "cancelled" ] , num_splits) ,
1778+ ( Err ( _) , Err ( _) ) => ( [ "planning-failed" ] , 0 ) ,
1779+ // Should not happen, num split is resolved before the query
1780+ ( Ok ( _) , Err ( _) ) => ( [ "unexpected" ] , 0 ) ,
1781+ } ;
17801782
17811783 SEARCH_METRICS
17821784 . root_search_requests_total
0 commit comments