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
fix: sync service otel (#5292)
Wolf Mermelsteinde8e87a9f452
diff --git a/.github/actions/setup-rust/action.yml b/.github/actions/setup-rust/action.ymlindex c2277d027b..047f53e8f1 100644--- a/.github/actions/setup-rust/action.yml+++ b/.github/actions/setup-rust/action.yml@@ -20,6 +20,15 @@ runs:run: |set -euo pipefail+ # Namespace runners do not always include Rust; rustup installs into+ # ~/.cargo/bin, which also needs to be visible to later steps.+ export PATH="$HOME/.cargo/bin:$PATH"+ echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"++ if ! command -v rustup >/dev/null 2>&1; then+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal+ fi+if [[ -f rust-toolchain.toml ]]; thentoolchain="$(grep -E '^[[:space:]]*channel[[:space:]]*=' rust-toolchain.toml | sed -E 's/.*"([^"]+)".*/\1/')"elsediff --git a/.github/workflows/deploy_web_app.yml b/.github/workflows/deploy_web_app.ymlindex 802c6b05da..19d2037435 100644--- a/.github/workflows/deploy_web_app.yml+++ b/.github/workflows/deploy_web_app.yml@@ -64,6 +64,8 @@ jobs:env:VITE_SEGMENT_WRITE_KEY: ${{ secrets.SEGMENT_WRITE_KEY }}VITE_POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}+ VITE_OTEL_EXPORTER_URL: ${{ inputs.environment == 'prod' && 'https://macro-prox-prod.macroverse.workers.dev/i/otlp/v1/traces' || 'https://macro-prox-dev.macroverse.workers.dev/i/otlp/v1/traces' }}+ VITE_OTEL_ENV: ${{ inputs.environment == 'prod' && 'production' || 'development' }}working-directory: apps/web- name: Install infra dependenciesrun: bun installdiff --git a/.github/workspace-dep-closures.json b/.github/workspace-dep-closures.jsonindex d1a0d40e0c..4a5b2a25ae 100644--- a/.github/workspace-dep-closures.json+++ b/.github/workspace-dep-closures.json@@ -2668,7 +2668,6 @@"crates/ai_toolset","crates/ai_usage","crates/attachment",- "crates/authentication_service_client","crates/bot_id","crates/channel_sender","crates/channels",@@ -2676,14 +2675,9 @@"crates/connection_gateway_models","crates/contacts","crates/cowlike",- "crates/crm","crates/document_sub_type",- "crates/email",- "crates/email_db_client",- "crates/email_utils","crates/entity_access","crates/entity_access_db_utils",- "crates/entity_access_management","crates/entity_mutation","crates/filter_ast","crates/frecency",@@ -2709,9 +2703,7 @@"crates/model_file_type","crates/model_notifications","crates/model_user",- "crates/models_ai_projection","crates/models_bulk_upload",- "crates/models_email","crates/models_entity_access_management","crates/models_pagination","crates/models_permissions",@@ -2719,15 +2711,10 @@"crates/non_empty","crates/notification","crates/prompt",- "crates/properties","crates/rate_limit","crates/remote_env_var",- "crates/s3_key","crates/share_permission_db_utils",- "crates/sqs_client","crates/sqs_worker",- "crates/system_properties",- "crates/unfurl","crates/workspace-hack"],"graphql_common": [diff --git a/services/analytics-proxy/wrangler.jsonc b/services/analytics-proxy/wrangler.jsoncindex b279468698..6403cc324a 100644--- a/services/analytics-proxy/wrangler.jsonc+++ b/services/analytics-proxy/wrangler.jsonc@@ -18,14 +18,11 @@],"vars": {"POSTHOG_HOST": "https://us.i.posthog.com",- // Full origins (scheme included) the `/i/otlp` route forwards to, split- // per signal because Datadog has no single OTLP origin: traces and logs- // use different intake hosts. In deployed envs the server-side dd-api-key- // is injected (a secret set via `wrangler secret put DD_API_KEY`, never- // committed here). In the local pool the docker command overrides both to- // the otel-collector alias via --var (one collector serves both paths).- "OTLP_TRACES_INTAKE_URL": "https://trace.agent.us5.datadoghq.com",- "OTLP_LOGS_INTAKE_URL": "https://otlp-http-intake.logs.us5.datadoghq.com"+ // Datadog's Cloudflare managed-platform endpoint accepts both OTLP signals.+ // The server-side dd-api-key is injected from a Worker secret. The local+ // pool overrides both origins to its collector via --var.+ "OTLP_TRACES_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com",+ "OTLP_LOGS_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com"},"env": {"local": {@@ -54,8 +51,8 @@],"vars": {"POSTHOG_HOST": "https://us.i.posthog.com",- "OTLP_TRACES_INTAKE_URL": "https://trace.agent.us5.datadoghq.com",- "OTLP_LOGS_INTAKE_URL": "https://otlp-http-intake.logs.us5.datadoghq.com"+ "OTLP_TRACES_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com",+ "OTLP_LOGS_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com"}},"prod": {@@ -68,8 +65,8 @@],"vars": {"POSTHOG_HOST": "https://us.i.posthog.com",- "OTLP_TRACES_INTAKE_URL": "https://trace.agent.us5.datadoghq.com",- "OTLP_LOGS_INTAKE_URL": "https://otlp-http-intake.logs.us5.datadoghq.com"+ "OTLP_TRACES_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com",+ "OTLP_LOGS_INTAKE_URL": "https://cloudflare.integrations.otlp.us5.datadoghq.com"}}},diff --git a/services/sync-service/src/cf_worker.rs b/services/sync-service/src/cf_worker.rsindex f4f9778ad8..bddbe68b04 100644--- a/services/sync-service/src/cf_worker.rs+++ b/services/sync-service/src/cf_worker.rs@@ -142,10 +142,16 @@ pub async fn pass_to_durable_object() -> Result<Response> {let stub = get_durable_object(env, document_id)?;let span = tracing::info_span!("do.fetch", document.id = %document_id);- if let Some(traceparent) = worker_rs_otel::traceparent_for_span(&span) {- req.headers()- .set(worker_rs_otel::TRACEPARENT, &traceparent)?;- }+ let req = match worker_rs_otel::traceparent_for_span(&span) {+ Some(traceparent) => {+ let mut cloned = req.clone_mut()?;+ cloned+ .headers_mut()?+ .set(worker_rs_otel::TRACEPARENT, &traceparent)?;+ cloned+ }+ None => req,+ };let fut = timeout(stub.fetch_with_request(req), DEFAULT_TIMEOUT_MS).instrument(span);let res = timeit_log!("worker -> do_fetch", fut.await);diff --git a/services/sync-service/src/dss_internal.rs b/services/sync-service/src/dss_internal.rsindex 54ae81762d..9bb8beb735 100644--- a/services/sync-service/src/dss_internal.rs+++ b/services/sync-service/src/dss_internal.rs@@ -52,7 +52,14 @@ impl<'a> DssInternalClient<'a> {}fn internal_auth_key(&self) -> worker::Result<String> {- Ok(self.env.var("DSS_INTERNAL_AUTH_KEY")?.to_string())+ self.env+ .secret("DSS_INTERNAL_AUTH_KEY")+ .map(|value| value.to_string())+ .or_else(|_| {+ self.env+ .var("DSS_INTERNAL_AUTH_KEY")+ .map(|value| value.to_string())+ })}}diff --git a/services/sync-service/src/secrets.rs b/services/sync-service/src/secrets.rsindex e52f587812..3c77483e58 100644--- a/services/sync-service/src/secrets.rs+++ b/services/sync-service/src/secrets.rs@@ -22,11 +22,13 @@ impl From<&Env> for Secrets {.unwrap_or_else(|_e| panic!("Couldn't get secret secret for internal API key")).to_string();let document_permissions_secret = env- .var("DOCUMENT_PERMISSIONS_SECRET")- .unwrap_or_else(|e| {- panic!("Couldn't get DOCUMENT_PERMISSIONS_SECRET environment variable: {e}")+ .secret("DOCUMENT_PERMISSIONS_SECRET")+ .map(|value| value.to_string())+ .or_else(|_| {+ env.var("DOCUMENT_PERMISSIONS_SECRET")+ .map(|value| value.to_string())})- .to_string();+ .unwrap_or_else(|e| panic!("Couldn't get DOCUMENT_PERMISSIONS_SECRET: {e}"));Self {internal_api_secret,diff --git a/services/sync-service/wrangler.toml b/services/sync-service/wrangler.tomlindex 9252dfcd7d..f80ba658cd 100644--- a/services/sync-service/wrangler.toml+++ b/services/sync-service/wrangler.toml@@ -99,6 +99,8 @@ name = "sync-service-dev3"[env.dev.vars]INTERNAL_API_SECRET_KEY = "SYNC_SERVICE_KEY_DEV"ENVIRONMENT = "development"+# The proxy injects the Datadog key; the exporter appends the signal path.+OTEL_EXPORTER_OTLP_ENDPOINT = "https://macro-prox-dev.macroverse.workers.dev/i/otlp"SPS_URL = "https://search-processing-dev.macro.com"DSS_URL = "https://cloud-storage-dev.macro.com"@@ -137,6 +139,8 @@ name = "sync-service-prod2"[env.prod.vars]INTERNAL_API_SECRET_KEY = "SYNC_SERVICE_KEY_PROD"ENVIRONMENT = "production"+# The proxy injects the Datadog key; the exporter appends the signal path.+OTEL_EXPORTER_OTLP_ENDPOINT = "https://macro-prox-prod.macroverse.workers.dev/i/otlp"SPS_URL = "https://search-processing.macro.com"DSS_URL = "https://cloud-storage.macro.com"diff --git a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rsindex 07635b6ca3..725a8f6076 100644--- a/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs+++ b/tooling/xtask/crates/xtask_workflows/src/workflows/deploy_web_app.rs@@ -123,6 +123,14 @@ fn build() -> Step<Run> {.working_directory(xtask_paths::repo_dir!("apps/web")).add_env(Env::new("VITE_SEGMENT_WRITE_KEY", vars::SEGMENT_WRITE_KEY)).add_env(Env::new("VITE_POSTHOG_API_KEY", vars::POSTHOG_API_KEY))+ .add_env(Env::new(+ "VITE_OTEL_EXPORTER_URL",+ "${{ inputs.environment == 'prod' && 'https://macro-prox-prod.macroverse.workers.dev/i/otlp/v1/traces' || 'https://macro-prox-dev.macroverse.workers.dev/i/otlp/v1/traces' }}",+ ))+ .add_env(Env::new(+ "VITE_OTEL_ENV",+ "${{ inputs.environment == 'prod' && 'production' || 'development' }}",+ ))}fn install_infra_dependencies() -> Step<Run> {