Skip to content

Commit be5e543

Browse files
sjuddConvex, Inc.
authored and
Convex, Inc.
committed
Call finish on a bunch of search related status timers (#27111)
If we don't call finish, they default to errors, which isn't what we want here. GitOrigin-RevId: e8c186ee92f93ff05a6f25857a7dc3bd2b8fb64c
1 parent d6581b8 commit be5e543

File tree

1 file changed

+13
-7
lines changed

1 file changed

+13
-7
lines changed

crates/search/src/searcher/searcher.rs

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -527,13 +527,14 @@ impl<RT: Runtime> Searcher for SearcherImpl<RT> {
527527
search_storage: Arc<dyn Storage>,
528528
storage_key: ObjectKey,
529529
) -> anyhow::Result<usize> {
530-
let _timer = text_number_of_segments_searcher_latency_seconds();
530+
let timer = text_number_of_segments_searcher_latency_seconds();
531531
let segment_path = self
532532
.archive_cache
533533
.get(search_storage.clone(), &storage_key, SearchFileType::Text)
534534
.await?;
535535
let reader = index_reader_for_directory(segment_path)?;
536536
let searcher = reader.searcher();
537+
timer.finish();
537538
Ok(searcher.segment_readers().len())
538539
}
539540

@@ -545,10 +546,11 @@ impl<RT: Runtime> Searcher for SearcherImpl<RT> {
545546
queries: Vec<TokenQuery>,
546547
max_results: usize,
547548
) -> anyhow::Result<Vec<TokenMatch>> {
548-
let _timer = text_query_tokens_searcher_latency_seconds();
549+
let timer = text_query_tokens_searcher_latency_seconds();
549550
let text_segment = self.load_text_segment(search_storage, storage_keys).await?;
550551
let query = move || Self::query_tokens_impl(text_segment, queries, max_results);
551552
let resp = self.text_search_pool.execute(query).await??;
553+
timer.finish();
552554
Ok(resp)
553555
}
554556

@@ -559,10 +561,11 @@ impl<RT: Runtime> Searcher for SearcherImpl<RT> {
559561
storage_keys: TextStorageKeys,
560562
terms: Vec<Term>,
561563
) -> anyhow::Result<Bm25Stats> {
562-
let _timer = text_query_bm25_searcher_latency_seconds();
564+
let timer = text_query_bm25_searcher_latency_seconds();
563565
let text_segment = self.load_text_segment(search_storage, storage_keys).await?;
564566
let query = move || Self::query_bm25_stats_impl(text_segment, terms);
565567
let resp = self.text_search_pool.execute(query).await??;
568+
timer.finish();
566569
Ok(resp)
567570
}
568571

@@ -573,10 +576,11 @@ impl<RT: Runtime> Searcher for SearcherImpl<RT> {
573576
storage_keys: TextStorageKeys,
574577
query: PostingListQuery,
575578
) -> anyhow::Result<Vec<PostingListMatch>> {
576-
let _timer = text_query_posting_lists_searcher_latency_seconds();
579+
let timer = text_query_posting_lists_searcher_latency_seconds();
577580
let text_segment = self.load_text_segment(search_storage, storage_keys).await?;
578581
let query = move || Self::query_posting_lists_impl(text_segment, query);
579582
let resp = self.text_search_pool.execute(query).await??;
583+
timer.finish();
580584
Ok(resp)
581585
}
582586

@@ -586,15 +590,17 @@ impl<RT: Runtime> Searcher for SearcherImpl<RT> {
586590
search_storage: Arc<dyn Storage>,
587591
segments: Vec<FragmentedTextStorageKeys>,
588592
) -> anyhow::Result<FragmentedTextSegment> {
589-
let _timer = text_compaction_searcher_latency_seconds();
590-
fetch_compact_and_upload_text_segment(
593+
let timer = text_compaction_searcher_latency_seconds();
594+
let result = fetch_compact_and_upload_text_segment(
591595
&self.rt,
592596
search_storage,
593597
self.archive_cache.clone(),
594598
self.text_search_pool.clone(),
595599
segments,
596600
)
597-
.await
601+
.await;
602+
timer.finish();
603+
result
598604
}
599605
}
600606

0 commit comments

Comments
 (0)