From 009ccee72be194d671cff5caee3acf9f120eb5c1 Mon Sep 17 00:00:00 2001 From: ZhenYi <434836402@qq.com> Date: Wed, 29 Apr 2026 15:35:25 +0800 Subject: [PATCH] fix(embed): add debug tracing to all embed methods Added tracing::debug/info calls to embed_issue, embed_repo, embed_issues, embed_skill to track embedding API calls and upsert completion. --- libs/agent/embed/service.rs | 30 +++++++++++++++++++++++++----- 1 file changed, 25 insertions(+), 5 deletions(-) diff --git a/libs/agent/embed/service.rs b/libs/agent/embed/service.rs index b4f58d7..8a9bf44 100644 --- a/libs/agent/embed/service.rs +++ b/libs/agent/embed/service.rs @@ -118,7 +118,9 @@ impl EmbedService { _ => title.to_string(), }; + tracing::debug!(issue_id = %id, text_len = text.len(), "embed_issue: calling embedding API"); let vector = self.client.embed_text(&text, &self.model_name).await?; + tracing::debug!(issue_id = %id, vec_dim = vector.len(), "embed_issue: embedding done"); let point = EmbedVector { id: id.to_string(), @@ -131,7 +133,9 @@ impl EmbedService { }, }; - self.client.upsert(vec![point]).await + self.client.upsert(vec![point]).await?; + tracing::info!(issue_id = %id, "embed_issue: upsert complete"); + Ok(()) } pub async fn embed_repo( @@ -145,7 +149,9 @@ impl EmbedService { _ => name.to_string(), }; + tracing::debug!(repo_id = %id, text_len = text.len(), "embed_repo: calling embedding API"); let vector = self.client.embed_text(&text, &self.model_name).await?; + tracing::debug!(repo_id = %id, vec_dim = vector.len(), "embed_repo: embedding done"); let point = EmbedVector { id: id.to_string(), @@ -158,7 +164,9 @@ impl EmbedService { }, }; - self.client.upsert(vec![point]).await + self.client.upsert(vec![point]).await?; + tracing::info!(repo_id = %id, "embed_repo: upsert complete"); + Ok(()) } pub async fn embed_issues( @@ -170,7 +178,9 @@ impl EmbedService { } let texts: Vec = items.iter().map(|i| i.to_text()).collect(); + tracing::debug!(count = texts.len(), "embed_issues: calling embed_batch"); let embeddings = self.client.embed_batch(&texts, &self.model_name).await?; + tracing::debug!(count = embeddings.len(), "embed_issues: batch done"); let points: Vec = items .into_iter() @@ -187,7 +197,10 @@ impl EmbedService { }) .collect(); - self.client.upsert(points).await + let count = points.len(); + self.client.upsert(points).await?; + tracing::info!(count = count, "embed_issues: upsert complete"); + Ok(()) } pub async fn search_issues( @@ -264,15 +277,20 @@ impl EmbedService { let desc = description.unwrap_or_default(); let id = skill_id.to_string(); + tracing::debug!(skill_id = %skill_id, name = %name, content_len = content.len(), "embed_skill: starting"); + // Auto-chunk long content let texts = chunk_text(content); + tracing::debug!(skill_id = %skill_id, chunks = texts.len(), "embed_skill: chunked"); + if texts.len() == 1 { self.client .embed_skill(&id, name, desc, content, project_uuid, &self.model_name) - .await + .await?; } else { // Multi-chunk: embed each chunk with chunk_index metadata let full_texts: Vec = texts.iter().map(|t| format!("{}: {} {}", name, desc, t)).collect(); + tracing::debug!(skill_id = %skill_id, "embed_skill: calling embed_batch"); let embeddings = self.client.embed_batch(&full_texts, &self.model_name).await?; let points: Vec = embeddings.into_iter().enumerate().map(|(i, vector)| { @@ -293,8 +311,10 @@ impl EmbedService { } }).collect(); - self.client.upsert(points).await + self.client.upsert(points).await?; } + tracing::info!(skill_id = %skill_id, chunks = texts.len(), "embed_skill: complete"); + Ok(()) } /// Embed an issue with auto-chunking for long content.