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(email-service): Better logging for link manager (#1169)
Evan Hutnik3e08370e5e80
diff --git a/.github/workflows/code-check-cloud-storage.yml b/.github/workflows/code-check-cloud-storage.ymlindex 21c7c1c27e..a2340ec48a 100644--- a/.github/workflows/code-check-cloud-storage.yml+++ b/.github/workflows/code-check-cloud-storage.yml@@ -76,7 +76,7 @@ jobs:run: |command -v just || cargo install justcommand -v sqlx || cargo install sqlx-cli- command -v cargo-nextest || cargo install cargo-nextest+ command -v cargo-nextest || cargo install cargo-nextest --locked- name: prepare testsrun: |just rust/cloud-storage/setup_test_envsdiff --git a/rust/cloud-storage/email_service/src/api/email/init.rs b/rust/cloud-storage/email_service/src/api/email/init.rsindex b0d91959b3..4e293a4d73 100644--- a/rust/cloud-storage/email_service/src/api/email/init.rs+++ b/rust/cloud-storage/email_service/src/api/email/init.rs@@ -80,7 +80,7 @@ pub struct InitResponse {(status = 500, body=ErrorResponse),))]-#[tracing::instrument(skip(ctx, user_context, gmail_token), fields(user_id=user_context.user_id, fusionauth_user_id=user_context.fusion_user_id))]+#[tracing::instrument(skip(ctx, user_context, gmail_token), fields(user_id=user_context.user_id, fusionauth_user_id=user_context.fusion_user_id), err)]pub async fn handler(State(ctx): State<ApiContext>,MacroUserExtractor {@@ -190,7 +190,7 @@ pub async fn handler(/// Enables Gmail sync for a user by A) registering a watch with Gmail API B) updating the link record/// to is_sync_active = true and C) updating gmail_histories entry with the current history value.-#[tracing::instrument(skip(ctx, user_context, gmail_access_token))]+#[tracing::instrument(skip(ctx, user_context, gmail_access_token), fields(user_id=user_context.user_id, fusionauth_user_id=user_context.fusion_user_id), err)]pub async fn enable_gmail_sync(ctx: &ApiContext,user_context: &UserContext,diff --git a/rust/cloud-storage/email_service/src/pubsub/link_manager/process.rs b/rust/cloud-storage/email_service/src/pubsub/link_manager/process.rsindex 74a5d8e8a8..83a07161b6 100644--- a/rust/cloud-storage/email_service/src/pubsub/link_manager/process.rs+++ b/rust/cloud-storage/email_service/src/pubsub/link_manager/process.rs@@ -12,6 +12,7 @@ use sqs_client::search::SearchQueueMessage;use sqs_client::search::email::EmailLinkMessage;use sqs_worker::cleanup_message;+#[tracing::instrument(skip(ctx, message), err)]pub async fn process_message(ctx: LinkManagerContext,message: &aws_sdk_sqs::types::Message,@@ -63,6 +64,7 @@ pub async fn process_message(}/// Handles the Refresh operation: renews Gmail watch subscription and syncs contacts.+#[tracing::instrument(skip(ctx, gmail_access_token), fields(link = ?link), err)]async fn handle_refresh(ctx: &LinkManagerContext,link: &Link,@@ -73,7 +75,7 @@ async fn handle_refresh(renew_gmail_watch(ctx, gmail_access_token, link).await.inspect_err(|e| {- tracing::error!(error=?e, link_id=%link.id, "Failed to renew Gmail watch");+ tracing::error!(error=?e, "Failed to renew Gmail watch");}).ok();@@ -89,7 +91,6 @@ async fn handle_refresh({tracing::error!(error = ?e,- link_id = %link.id,"Failed to sync contacts");}@@ -100,12 +101,13 @@ async fn handle_refresh(}/// notifies downstream dependencies of link deletion, and deletes link (and all data) from database+#[tracing::instrument(skip(ctx, gmail_access_token), fields(link = ?link), err)]async fn handle_delete(ctx: &LinkManagerContext,link: &Link,gmail_access_token: Option<&str>,) -> anyhow::Result<()> {- tracing::info!(link=?link, "Deleting link");+ tracing::info!("Deleting link");// set sync status to false so any future inbox updates get ignoredemail_db_client::links::update::update_link_sync_status(&ctx.db, link.id, false).await@@ -115,7 +117,7 @@ async fn handle_delete(email_db_client::backfill::job::update::cancel_active_jobs_by_link_id(&ctx.db, link.id).await.inspect_err(|e| {- tracing::error!(error=?e, link_id=?link.id, "Failed to update backfill job statuses");+ tracing::error!(error=?e, "Failed to update backfill job statuses");}).ok();@@ -136,10 +138,10 @@ async fn handle_delete(// that we may be deleting their link in the first place)if let Some(token) = gmail_access_token {if let Err(e) = ctx.gmail_client.stop_watch(token).await {- tracing::warn!(error=?e, link_id=?link.id, "Gmail call to stop watch failed");+ tracing::warn!(error=?e, "Gmail call to stop watch failed");}} else {- tracing::debug!(link_id=?link.id, "Skipping Gmail stop_watch - no access token available");+ tracing::debug!("Skipping Gmail stop_watch - no access token available");}// remove google fusionauth link with gmail inbox permissions@@ -172,7 +174,7 @@ async fn handle_delete(.await.context("Failed to delete link in background task")?;- tracing::info!(link_id=?link.id, "Successfully deleted link");+ tracing::info!("Successfully deleted link");Ok(())}