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
Seanaye/fix/target for span (#5250)
Sean Aye78ee9588aa23
diff --git a/crates/macro_entrypoint/src/test.rs b/crates/macro_entrypoint/src/test.rsindex 66de4dd691..87b0369134 100644--- a/crates/macro_entrypoint/src/test.rs+++ b/crates/macro_entrypoint/src/test.rs@@ -142,6 +142,50 @@ fn rust_log_warn_does_not_drop_info_spans() {assert!(!output.contains("info event is filtered from logs"));}+#[test]+fn rust_log_target_directive_includes_info_span_fields_in_warn_log() {+ let json_format = tracing_subscriber::fmt::format::Format::default()+ .json()+ .with_current_span(true)+ .with_span_list(false)+ .flatten_event(true);++ let logs = SharedWriter::default();+ let fmt_layer = tracing_subscriber::fmt::layer()+ .with_ansi(false)+ .fmt_fields(tracing_subscriber::fmt::format::JsonFields::new())+ .event_format(datadog_fmt::DatadogFormat { inner: json_format })+ .with_writer(logs.clone())+ .with_filter(EnvFilter::new("warn,macro_http_request=info"));+ let subscriber = Registry::default().with(fmt_layer);++ tracing::subscriber::with_default(subscriber, || {+ tracing::info_span!(+ target: "macro_http_request",+ "http.request",+ "http.request.method" = "POST",+ "url.path" = "/documents",+ "request.id" = "req-123",+ )+ .in_scope(|| {+ tracing::warn!("slow http request");+ tracing::info!(target: "other_target", "filtered info event");+ });+ });++ let output = logs.contents();+ let line = output+ .lines()+ .find(|line| line.contains("slow http request"))+ .expect("warn event should be logged");+ let json = serde_json::from_str::<serde_json::Value>(line).unwrap();+ assert_eq!(json["span"]["name"], "http.request", "{output}");+ assert_eq!(json["span"]["http.request.method"], "POST");+ assert_eq!(json["span"]["url.path"], "/documents");+ assert_eq!(json["span"]["request.id"], "req-123");+ assert!(!output.contains("filtered info event"));+}+#[test]fn global_warn_filter_drops_info_spans() {let (exporter, provider) = test_tracer_provider();diff --git a/crates/macro_tower_layers/src/lib.rs b/crates/macro_tower_layers/src/lib.rsindex a6825a0d80..d10242f3ae 100644--- a/crates/macro_tower_layers/src/lib.rs+++ b/crates/macro_tower_layers/src/lib.rs@@ -56,9 +56,12 @@ impl CustomOnResponse {}}+const HTTP_REQUEST_SPAN_TARGET: &str = "macro_http_request";+/// Creates INFO-level HTTP server spans with safe OpenTelemetry attributes.///-/// Request and response headers are intentionally excluded.+/// Request and response headers are intentionally excluded. Add+/// `macro_http_request=info` to `RUST_LOG` when log events should include these span fields.#[derive(Clone, Copy, Debug, Default)]pub struct MakeHttpRequestSpan;@@ -71,6 +74,7 @@ impl<B> MakeSpan<B> for MakeHttpRequestSpan {.unwrap_or_default();tracing::info_span!(+ target: HTTP_REQUEST_SPAN_TARGET,"http.request",otel.kind = "server","http.request.method" = %request.method(),diff --git a/crates/macro_tower_layers/src/test.rs b/crates/macro_tower_layers/src/test.rsindex 8c4e9dcce0..bd51f37fc1 100644--- a/crates/macro_tower_layers/src/test.rs+++ b/crates/macro_tower_layers/src/test.rs@@ -14,6 +14,7 @@ use tracing::{struct CapturedTracing {event_levels: Mutex<Vec<Level>>,span_level: Mutex<Option<Level>>,+ span_target: Mutex<Option<String>>,declared_span_fields: Mutex<HashSet<String>>,initial_span_fields: Mutex<HashMap<String, String>>,recorded_span_fields: Mutex<HashMap<String, String>>,@@ -61,6 +62,7 @@ impl tracing::Subscriber for TracingCapture {fn new_span(&self, attrs: &tracing::span::Attributes<'_>) -> tracing::span::Id {*self.captured.span_level.lock().unwrap() = Some(*attrs.metadata().level());+ *self.captured.span_target.lock().unwrap() = Some(attrs.metadata().target().to_owned());*self.captured.declared_span_fields.lock().unwrap() = attrs.metadata().fields()@@ -111,6 +113,10 @@ fn request_span_uses_info_and_safe_structured_fields() {});assert_eq!(*captured.span_level.lock().unwrap(), Some(Level::INFO));+ assert_eq!(+ captured.span_target.lock().unwrap().as_deref(),+ Some(HTTP_REQUEST_SPAN_TARGET)+ );let declared_fields = captured.declared_span_fields.lock().unwrap();assert!(declared_fields.contains("http.request.method"));diff --git a/infra/packages/lambda/src/worker_trigger_lambda.ts b/infra/packages/lambda/src/worker_trigger_lambda.tsindex 907ab0486b..2140417fb0 100644--- a/infra/packages/lambda/src/worker_trigger_lambda.ts+++ b/infra/packages/lambda/src/worker_trigger_lambda.ts@@ -34,7 +34,7 @@ export class WorkerTrigger extends pulumi.ComponentResource {CLUSTER: pulumi.interpolate`${clusterArn}`,SUBNETS: coparse_api_vpc.privateSubnetIds.join(','),ENVIRONMENT: stack,- RUST_LOG: 'worker_trigger=info',+ RUST_LOG: 'worker_trigger=info,macro_http_request=info',};const ecsAccessPolicy = new aws.iam.Policy(diff --git a/infra/stacks/authentication-service/index.ts b/infra/stacks/authentication-service/index.tsindex 6292f8d7eb..616eb60d10 100644--- a/infra/stacks/authentication-service/index.ts+++ b/infra/stacks/authentication-service/index.ts@@ -167,7 +167,7 @@ new UserLinkCleanupHandler('user-link-cleanup-handler', {envVars: {DATABASE_URL: pulumi.interpolate`${DATABASE_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'user_link_cleanup_handler=info',+ RUST_LOG: 'user_link_cleanup_handler=info,macro_http_request=info',},vpc,tags,diff --git a/infra/stacks/bulk-upload/index.ts b/infra/stacks/bulk-upload/index.tsindex 5f5870f276..33fa5bb5d3 100644--- a/infra/stacks/bulk-upload/index.ts+++ b/infra/stacks/bulk-upload/index.ts@@ -133,7 +133,8 @@ if (stack !== 'local') {envVars: {DYNAMODB_TABLE: pulumi.interpolate`${dynamoTableName}`,ENVIRONMENT: stack,- RUST_LOG: 'upload_extractor_lambda_trigger=trace',+ RUST_LOG:+ 'upload_extractor_lambda_trigger=trace,macro_http_request=info',},uploadExtractorQueueArn: bulkUploadQueue.queue.arn,uploadBucketName: pulumi.interpolate`${bulkUploadBucket.bucket.bucket}`,@@ -153,7 +154,8 @@ if (stack !== 'local') {ServiceUrl.CONNECTION_GATEWAY_URL),ENVIRONMENT: stack,- RUST_LOG: 'upload_extractor_lambda_handler=trace',+ RUST_LOG:+ 'upload_extractor_lambda_handler=trace,macro_http_request=info',},uploadExtractorQueueArn: bulkUploadQueue.queue.arn,uploadBucketArn: pulumi.interpolate`${bulkUploadBucket.bucket.arn}`,diff --git a/infra/stacks/call-recording/index.ts b/infra/stacks/call-recording/index.tsindex 38db09bca7..1f4f2c3341 100644--- a/infra/stacks/call-recording/index.ts+++ b/infra/stacks/call-recording/index.ts@@ -270,7 +270,7 @@ const previewLambdaEnvVars: CallRecordingPreviewLambdaEnvVars = {FFMPEG_PATH: '/opt/bin/ffmpeg',FFPROBE_PATH: '/opt/bin/ffprobe',ENVIRONMENT: stack,- RUST_LOG: 'call_recording_preview_handler=trace',+ RUST_LOG: 'call_recording_preview_handler=trace,macro_http_request=info',};const callRecordingPreviewLambda = new CallRecordingPreviewLambda(diff --git a/infra/stacks/cloud-storage-service/index.ts b/infra/stacks/cloud-storage-service/index.tsindex bab7dcc820..dc12ee2aea 100644--- a/infra/stacks/cloud-storage-service/index.ts+++ b/infra/stacks/cloud-storage-service/index.ts@@ -203,7 +203,7 @@ const deleteChatHandler = new DeleteChatHandler(envVars: {DATABASE_URL: pulumi.interpolate`${DATABASE_URL_PROXY}`,ENVIRONMENT: stack,- RUST_LOG: 'delete_chat_handler=info',+ RUST_LOG: 'delete_chat_handler=info,macro_http_request=info',},vpc: coparse_api_vpc,tags,@@ -322,7 +322,7 @@ const docxUnzipHandlerEnvVars: DocxUnzipLambdaEnvVars = {DATABASE_URL: pulumi.interpolate`${DATABASE_URL_PROXY}`,REDIS_URI: pulumi.interpolate`redis://${MACRO_CACHE}`,ENVIRONMENT: stack,- RUST_LOG: 'docx_unzip_handler=info',+ RUST_LOG: 'docx_unzip_handler=info,macro_http_request=info',DOCUMENT_STORAGE_BUCKET: pulumi.interpolate`${documentStorageBucketId}`,DOCX_DOCUMENT_UPLOAD_BUCKET: pulumi.interpolate`${docxUploadBucketName}`,WEB_SOCKET_RESPONSE_LAMBDA: pulumi.interpolate`${jobUpdateHandlerLambdaName}`,@@ -351,7 +351,8 @@ const documentUploadFinalizerEnvVars: DocumentUploadFinalizerLambdaEnvVars = {SYNC_SERVICE_AUTH_KEY: pulumi.interpolate`${syncServiceAuthKeyValue}`,LEXICAL_SERVICE_URL: getServiceUrl(ServiceUrl.LEXICAL_SERVICE_URL),SYNC_SERVICE_URL: getServiceUrl(ServiceUrl.SYNC_SERVICE_URL),- RUST_LOG: 'document_upload_finalizer_handler=info,documents=info',+ RUST_LOG:+ 'document_upload_finalizer_handler=info,documents=info,macro_http_request=info',};const documentUploadFinalizer = new DocumentUploadFinalizerLambda(diff --git a/infra/stacks/deleted-item-poller/index.ts b/infra/stacks/deleted-item-poller/index.tsindex 2a49589bce..485bc0dd79 100644--- a/infra/stacks/deleted-item-poller/index.ts+++ b/infra/stacks/deleted-item-poller/index.ts@@ -41,7 +41,7 @@ const deletedItemPoller = new DeleteItemPoller('deleted-item-poller', {envVars: {DATABASE_URL: pulumi.interpolate`${DATABASE_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'deleted_item_poller=info',+ RUST_LOG: 'deleted_item_poller=info,macro_http_request=info',},tags,});diff --git a/infra/stacks/dlp-handler/index.ts b/infra/stacks/dlp-handler/index.tsindex a660b8b587..0964efb882 100644--- a/infra/stacks/dlp-handler/index.ts+++ b/infra/stacks/dlp-handler/index.ts@@ -15,7 +15,7 @@ if (stack === 'prod') {const dlpHandler = new DlpHandler(`dlp-handler-${stack}`, {envVars: {SNS_TOPIC_ARN: snsTopicArn,- RUST_LOG: 'dataloss_prevention_handler=info',+ RUST_LOG: 'dataloss_prevention_handler=info,macro_http_request=info',ENVIRONMENT: stack,},snsTopicArn,diff --git a/infra/stacks/document-cognition-service/index.ts b/infra/stacks/document-cognition-service/index.tsindex a453fab513..b16169ee2a 100644--- a/infra/stacks/document-cognition-service/index.ts+++ b/infra/stacks/document-cognition-service/index.ts@@ -123,7 +123,8 @@ const aiProjectionsRefreshTrigger = new AiProjectionsRefreshTrigger(envVars: {DATABASE_URL: pulumi.interpolate`${PROXY_DATABASE_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'ai_projections_refresh_handler=trace,sqs_client=trace',+ RUST_LOG:+ 'ai_projections_refresh_handler=trace,sqs_client=trace,macro_http_request=info',},aiProjectionQueueArn: aiProjectionQueue.queue.arn,vpc: coparse_api_vpc,diff --git a/infra/stacks/document-text-extractor/index.ts b/infra/stacks/document-text-extractor/index.tsindex d9a4cc01e2..b1ccfc6a06 100644--- a/infra/stacks/document-text-extractor/index.ts+++ b/infra/stacks/document-text-extractor/index.ts@@ -36,7 +36,7 @@ const documentStorageBucketId: pulumi.Output<string> = cloudStorageStackconst documentTextExtractorEnvVars: DocumentTextExtractorLambdaEnvVars = {DATABASE_URL: pulumi.interpolate`${DATABASE_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'document_text_extractor=trace',+ RUST_LOG: 'document_text_extractor=trace,macro_http_request=info',DOCUMENT_STORAGE_BUCKET: pulumi.interpolate`${documentStorageBucketId}`,};diff --git a/infra/stacks/email-service/index.ts b/infra/stacks/email-service/index.tsindex 74364a2d58..4c74578e31 100644--- a/infra/stacks/email-service/index.ts+++ b/infra/stacks/email-service/index.ts@@ -427,7 +427,7 @@ const emailRefreshHandler = new EmailRefreshHandler('email-refresh-handler', {envVars: {DATABASE_URL: pulumi.interpolate`${MACRO_DB_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'email_refresh_handler=info',+ RUST_LOG: 'email_refresh_handler=info,macro_http_request=info',DELETE_UNUSED_AFTER_DAYS: pulumi.interpolate`${DELETE_UNUSED_AFTER_DAYS}`,DELETE_INACTIVE_AFTER_DAYS: pulumi.interpolate`${DELETE_INACTIVE_AFTER_DAYS}`,INBOX_HEALTH_POLL_INTERVAL_HOURS: pulumi.interpolate`${INBOX_HEALTH_POLL_INTERVAL_HOURS}`,@@ -443,7 +443,7 @@ const emailScheduledHandler = new EmailScheduledHandler(envVars: {DATABASE_URL: pulumi.interpolate`${MACRO_DB_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'email_scheduled_handler=info',+ RUST_LOG: 'email_scheduled_handler=info,macro_http_request=info',},tags,}diff --git a/infra/stacks/email-sfs-delete-handler/index.ts b/infra/stacks/email-sfs-delete-handler/index.tsindex 68b82cc676..471b877808 100644--- a/infra/stacks/email-sfs-delete-handler/index.ts+++ b/infra/stacks/email-sfs-delete-handler/index.ts@@ -37,7 +37,7 @@ const emailSfsDeleteHandler = new EmailSfsDeleteHandler(envVars: {DATABASE_URL: pulumi.interpolate`${MACRO_DB_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'email_sfs_delete_handler=info',+ RUST_LOG: 'email_sfs_delete_handler=info,macro_http_request=info',},tags,}diff --git a/infra/stacks/email-suppression/index.ts b/infra/stacks/email-suppression/index.tsindex 19e7e9344c..0016457a62 100644--- a/infra/stacks/email-suppression/index.ts+++ b/infra/stacks/email-suppression/index.ts@@ -29,7 +29,7 @@ if (stack === 'prod') {const emailSuppressionEnvVars: EmailSuppressionLambdaEnvVars = {DATABASE_URL: pulumi.interpolate`${DATABASE_URL}`,ENVIRONMENT: stack,- RUST_LOG: 'email_suppression_handler=trace',+ RUST_LOG: 'email_suppression_handler=trace,macro_http_request=info',};emailSuppression = new EmailSuppressionLambda(`email-suppression-${stack}`, {diff --git a/infra/stacks/organization-retention/index.ts b/infra/stacks/organization-retention/index.tsindex ffae47597c..9805557881 100644--- a/infra/stacks/organization-retention/index.ts+++ b/infra/stacks/organization-retention/index.ts@@ -51,7 +51,7 @@ const organizationRetentionHandler = new OrganizationRetentionHandler(envVars: {DATABASE_URL: pulumi.interpolate`${DATABASE_URL_PROXY}`,ENVIRONMENT: stack,- RUST_LOG: 'organization_retention_handler=trace',+ RUST_LOG: 'organization_retention_handler=trace,macro_http_request=info',},deleteDocumentQueueArn,deleteChatQueueArn,@@ -75,7 +75,8 @@ const organizationRetentionTrigger = new OrganizationRetentionTrigger(envVars: {DATABASE_URL: pulumi.interpolate`${DATABASE_URL_PROXY}`,ENVIRONMENT: stack,- RUST_LOG: 'organization_retention_trigger=trace,sqs_client=trace',+ RUST_LOG:+ 'organization_retention_trigger=trace,sqs_client=trace,macro_http_request=info',},organizationRetentionQueueArn,vpc: coparse_api_vpc,diff --git a/infra/stacks/search-upload/index.ts b/infra/stacks/search-upload/index.tsindex 3fbb6a9cb3..287ed92713 100644--- a/infra/stacks/search-upload/index.ts+++ b/infra/stacks/search-upload/index.ts@@ -30,7 +30,7 @@ const searchUploadHandler = new SearchUploadHandler({envVars: {ENVIRONMENT: pulumi.interpolate`${stack}`,- RUST_LOG: 'search_upload_handler=info',+ RUST_LOG: 'search_upload_handler=info,macro_http_request=info',DOCUMENT_STORAGE_SERVICE_URL: getServiceUrl(ServiceUrl.DOCUMENT_STORAGE_SERVICE_URL),diff --git a/infra/stacks/sha-cleanup/index.ts b/infra/stacks/sha-cleanup/index.tsindex 35b3436cc8..035915fbb0 100644--- a/infra/stacks/sha-cleanup/index.ts+++ b/infra/stacks/sha-cleanup/index.ts@@ -54,7 +54,7 @@ const shaCleanupWorker = new ShaWorker('sha-cleanup-worker', {},{name: 'RUST_LOG',- value: 'sha_cleanup_worker=info',+ value: 'sha_cleanup_worker=info,macro_http_request=info',},{name: 'DOCUMENT_STORAGE_BUCKET',