From fdbe7fc960fc6b910c577e5bfe8d48719e6d89f8 Mon Sep 17 00:00:00 2001 From: Gabriel Gordon-Hall Date: Tue, 10 Oct 2023 17:26:29 +0100 Subject: [PATCH] debug logs for initialisation --- server/bleep/src/db.rs | 5 ++++- server/bleep/src/lib.rs | 15 ++++++++++++++- server/bleep/src/semantic.rs | 19 ++++++++++++++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/server/bleep/src/db.rs b/server/bleep/src/db.rs index b1f4a44807..ae96d8c64e 100644 --- a/server/bleep/src/db.rs +++ b/server/bleep/src/db.rs @@ -15,7 +15,10 @@ pub async fn init(config: &Configuration) -> Result { let data_dir = config.index_dir.to_string_lossy(); match connect(&data_dir).await { - Ok(pool) => Ok(pool), + Ok(pool) => { + debug!("successfully connected to DB"); + Ok(pool) + } Err(e) => { warn!( ?e, diff --git a/server/bleep/src/lib.rs b/server/bleep/src/lib.rs index 977446e381..192349f75c 100644 --- a/server/bleep/src/lib.rs +++ b/server/bleep/src/lib.rs @@ -149,15 +149,25 @@ impl Application { // Wipe existing dbs & caches if the schema has changed if config.source.index_version_mismatch() { + debug!("schema version mismatch, resetting state"); + Indexes::reset_databases(&config).await?; + debug!("resetting caches"); + cache::FileCache::new(sql.clone(), semantic.clone()) .reset(&repo_pool) .await?; + debug!("resetting semantic index"); semantic.reset_collection_blocking().await?; + + debug!("state reset complete"); } + + debug!("saving index version"); config.source.save_index_version()?; + debug!("initializing indexes"); let indexes = Indexes::new(&config).await?.into(); // Enforce capabilies and features depending on environment @@ -170,7 +180,10 @@ impl Application { // Analytics backend let analytics = match initialize_analytics(&config, tracking_seed, analytics_options) { - Ok(analytics) => Some(analytics), + Ok(analytics) => { + debug!("analytics initialized"); + Some(analytics) + } Err(err) => { warn!(?err, "failed to initialize analytics"); None diff --git a/server/bleep/src/semantic.rs b/server/bleep/src/semantic.rs index 50778b0afd..b5dd0999ed 100644 --- a/server/bleep/src/semantic.rs +++ b/server/bleep/src/semantic.rs @@ -27,6 +27,7 @@ pub use embedder::Embedder; use embedder::LocalEmbedder; use schema::{create_collection, EMBEDDING_DIM}; pub use schema::{Embedding, Payload}; +use tracing_subscriber::field::debug; #[derive(Error, Debug)] pub enum SemanticError { @@ -189,10 +190,13 @@ impl Semantic { qdrant_url: &str, config: Arc, ) -> Result { + debug!(qdrant_url, "initializing qdrant client"); let qdrant = QdrantClient::new(Some(QdrantClientConfig::from_url(qdrant_url))).unwrap(); match qdrant.has_collection(&config.collection_name).await { Ok(false) => { + debug!(name = config.collection_name, "creating qdrant collection"); + let CollectionOperationResponse { result, time } = create_collection(&config.collection_name, &qdrant) .await @@ -207,14 +211,25 @@ impl Semantic { assert!(result); } - Ok(true) => {} + Ok(true) => { + debug!( + name = config.collection_name, + "qdrant collection already exists" + ); + } Err(_) => return Err(SemanticError::QdrantInitializationError), } create_indexes(&config.collection_name, &qdrant).await?; + debug!(name = config.collection_name, "qdrant indexes created"); + if let Some(dylib_dir) = config.dylib_dir.as_ref() { init_ort_dylib(dylib_dir); + debug!( + dylib_dir = dylib_dir.to_string_lossy().as_ref(), + "initialized ORT dylib" + ); } #[cfg(feature = "ee")] @@ -227,6 +242,8 @@ impl Semantic { #[cfg(not(feature = "ee"))] let embedder: Arc = Arc::new(LocalEmbedder::new(model_dir)?); + debug!("initialized embedder"); + Ok(Self { qdrant: qdrant.into(), embedder,