Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.
TypeScript agentaiai-agentsall-in-onecrmcrm-systememaillinearmcpmessagingnotesnotionofficerustslackslack-alternativestartupstartup-toolstypescriptworkspace
chore: add granular tracing to opensearch response (#1707)
gbirman994c3ee7cb91
diff --git a/rust/cloud-storage/opensearch_client/src/search/unified.rs b/rust/cloud-storage/opensearch_client/src/search/unified.rsindex 8466f24358..d3e8f2b322 100644--- a/rust/cloud-storage/opensearch_client/src/search/unified.rs+++ b/rust/cloud-storage/opensearch_client/src/search/unified.rs@@ -23,6 +23,7 @@ use crate::{};use chrono::{DateTime, Utc};use models_search_cursor::{SearchCursorOption, SearchMethodCursor};+use tracing::Instrument;use crate::SearchOn;use models_opensearch::SearchEntityType;@@ -459,26 +460,44 @@ pub(crate) async fn search_unified(return Ok((Vec::new(), SearchCursorOption::Done));}- let response = client- .search(opensearch::SearchParts::Index(&search_indices))- .body(search_request)- .send()- .await- .map_client_error()- .await?;-- let bytes = response- .bytes()- .await- .map_err(|e| OpensearchClientError::HttpBytesError {- details: e.to_string(),- })?;-- let result: DefaultSearchResponse<UnifiedSearchIndex> = serde_json::from_slice(&bytes)- .map_err(|e| OpensearchClientError::SearchDeserializationFailed {- details: e.to_string(),- raw_body: String::from_utf8_lossy(&bytes).to_string(),- })?;+ let response = async {+ client+ .search(opensearch::SearchParts::Index(&search_indices))+ .body(search_request)+ .send()+ .await+ .map_client_error()+ .await+ }+ .instrument(tracing::info_span!("opensearch_http_request"))+ .await?;++ let bytes = async {+ response+ .bytes()+ .await+ .map_err(|e| OpensearchClientError::HttpBytesError {+ details: e.to_string(),+ })+ }+ .instrument(tracing::info_span!("opensearch_read_response_body"))+ .await?;++ tracing::info!(+ response_body_bytes = bytes.len(),+ "opensearch response size"+ );++ let result: DefaultSearchResponse<UnifiedSearchIndex> = {+ let _span = tracing::info_span!("opensearch_deserialize_response", body_size = bytes.len())+ .entered();+ serde_json::from_slice(&bytes).map_err(|e| {+ OpensearchClientError::SearchDeserializationFailed {+ details: e.to_string(),+ raw_body: String::from_utf8_lossy(&bytes).to_string(),+ }+ })?+ };let mut results: Vec<SearchHit> = result.hits.hits.into_iter().map(|h| h.into()).collect();diff --git a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rsindex 3f212088cc..ae0f5eb59c 100644--- a/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs+++ b/rust/cloud-storage/search_service/src/api/search/simple/simple_unified.rs@@ -599,14 +599,13 @@ pub(in crate::api::search) async fn perform_unified_search((status = 500, body=ErrorResponse),))]-#[tracing::instrument(skip(ctx, user_context), fields(user_id=user_context.user_id), err)]pub async fn handler(State(ctx): State<SearchHandlerState>,user_context: Extension<UserContext>,extract::Query(query_params): extract::Query<SearchPaginationParams>,extract::Json(req): extract::Json<UnifiedSearchRequest>,) -> Result<Json<SimpleSearchResponse>, SearchError> {- tracing::info!("simple_unified_search");+ tracing::info!(user_id = user_context.user_id, "simple_unified_search");let (results, _next_cursor) =perform_unified_search(&ctx, &user_context, query_params, req).await?;diff --git a/rust/cloud-storage/search_service/src/api/search/unified.rs b/rust/cloud-storage/search_service/src/api/search/unified.rsindex 55e8ab6222..e1e318938f 100644--- a/rust/cloud-storage/search_service/src/api/search/unified.rs+++ b/rust/cloud-storage/search_service/src/api/search/unified.rs@@ -36,14 +36,13 @@ use std::cmp::Ordering;(status = 500, body=ErrorResponse),))]-#[tracing::instrument(skip(ctx, user_context), fields(user_id=user_context.user_id), err)]pub async fn handler(State(ctx): State<SearchHandlerState>,user_context: Extension<UserContext>,extract::Query(query_params): extract::Query<SearchPaginationParams>,extract::Json(req): extract::Json<UnifiedSearchRequest>,) -> Result<Json<UnifiedSearchResponse>, SearchError> {- tracing::info!("unified_search");+ tracing::info!(user_id = user_context.user_id, "unified_search");let (results, next_cursor) =perform_unified_search(&ctx, &user_context, query_params, req).await?;