server: more instrumentation

This commit is contained in:
Bill Thiede 2024-12-16 19:21:05 -08:00
parent 607e9e2251
commit 0697a5ea41

View File

@ -9,7 +9,7 @@ use tantivy::{
schema::{Facet, IndexRecordOption, Value}, schema::{Facet, IndexRecordOption, Value},
DocAddress, Index, IndexReader, Searcher, TantivyDocument, TantivyError, Term, DocAddress, Index, IndexReader, Searcher, TantivyDocument, TantivyError, Term,
}; };
use tracing::{info_span, instrument}; use tracing::{info_span, instrument, Instrument};
use crate::{ use crate::{
compute_offset_limit, compute_offset_limit,
@ -55,6 +55,7 @@ impl TantivyConnection {
let start_time = std::time::Instant::now(); let start_time = std::time::Instant::now();
let p_uids: Vec<_> = sqlx::query_file!("sql/all-uids.sql") let p_uids: Vec<_> = sqlx::query_file!("sql/all-uids.sql")
.fetch_all(pool) .fetch_all(pool)
.instrument(info_span!("postgres query"))
.await? .await?
.into_iter() .into_iter()
.map(|r| r.uid) .map(|r| r.uid)
@ -65,6 +66,8 @@ impl TantivyConnection {
start_time.elapsed().as_secs_f32() start_time.elapsed().as_secs_f32()
); );
let t_span = info_span!("tantivy query");
let _enter = t_span.enter();
let start_time = std::time::Instant::now(); let start_time = std::time::Instant::now();
let (searcher, _query) = self.searcher_and_query(&Query::default())?; let (searcher, _query) = self.searcher_and_query(&Query::default())?;
let docs = searcher.search(&AllQuery, &DocSetCollector)?; let docs = searcher.search(&AllQuery, &DocSetCollector)?;
@ -85,6 +88,7 @@ impl TantivyConnection {
.expect("searcher.doc") .expect("searcher.doc")
}) })
.collect(); .collect();
drop(_enter);
info!( info!(
"refresh tantivy got {} uids in {}", "refresh tantivy got {} uids in {}",