diff --git a/app.arc b/app.arc index 43e7be1fa..6ff874bdb 100644 --- a/app.arc +++ b/app.arc @@ -168,4 +168,5 @@ mission-cloud-platform # Custom permissions for deployment on Mission Cloud Pla email-outgoing # Grant the Lambda function permission to send email; add email templates. email-incoming # Enable Lambda handlers for incoming emails nasa-gcn/architect-plugin-search # Add an AWS OpenSearch Serverless collection. +nasa-gcn/architect-plugin-tracing architect/plugin-lambda-invoker diff --git a/app/email-incoming/circulars/index.ts b/app/email-incoming/circulars/index.ts index cb0356625..14205414b 100644 --- a/app/email-incoming/circulars/index.ts +++ b/app/email-incoming/circulars/index.ts @@ -48,7 +48,15 @@ interface EmailProps { const fromName = 'GCN Circulars' -export const handler = createEmailIncomingMessageHandler( +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = createEmailIncomingMessageHandler( async ({ content }) => { const parsed = await parseEmailContentFromSource(content) const { address: userEmail, submittedHow } = getFromAddress(parsed.from) diff --git a/app/email-incoming/support/index.ts b/app/email-incoming/support/index.ts index 0f9561814..8e20d2ace 100644 --- a/app/email-incoming/support/index.ts +++ b/app/email-incoming/support/index.ts @@ -31,10 +31,15 @@ const origData = { log: console.log, } -/** - * Forward incoming emails to Zendesk. - */ -export const handler = createEmailIncomingMessageHandler( +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = createEmailIncomingMessageHandler( async ({ content, receipt: { recipients } }) => { let data = { recipients, emailData: content.toString(), ...origData } data = await transformRecipients(data) diff --git a/app/scheduled/ads/index.ts b/app/scheduled/ads/index.ts index 0973fc9be..6e5f856c8 100644 --- a/app/scheduled/ads/index.ts +++ b/app/scheduled/ads/index.ts @@ -41,7 +41,15 @@ async function* getAdsEntries() { } while (length) } -export async function handler() { +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = async function() { const db = await tables() const seenCircularIds = new Set() for await (const entries of getAdsEntries()) { diff --git a/app/scheduled/circulars/index.ts b/app/scheduled/circulars/index.ts index 9cb923446..aa687c2d6 100644 --- a/app/scheduled/circulars/index.ts +++ b/app/scheduled/circulars/index.ts @@ -10,7 +10,15 @@ import { sitemapAction } from './actions/sitemap' import { statsAction } from './actions/stats' import { jsonUploadAction, txtUploadAction } from './actions/tar' -export async function handler() { +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = async function() { await forAllCirculars( jsonUploadAction, txtUploadAction, diff --git a/app/table-streams/circulars/index.ts b/app/table-streams/circulars/index.ts index e1f191482..e92892550 100644 --- a/app/table-streams/circulars/index.ts +++ b/app/table-streams/circulars/index.ts @@ -39,7 +39,15 @@ async function putIndex(circular: Circular) { }) } -export const handler = createTriggerHandler( +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = createTriggerHandler( async ({ eventName, dynamodb }: DynamoDBRecord) => { const id = unmarshallTrigger(dynamodb!.Keys).circularId as number const promises = [] diff --git a/app/table-streams/synonyms/index.ts b/app/table-streams/synonyms/index.ts index 98b38f81e..48ad42ec5 100644 --- a/app/table-streams/synonyms/index.ts +++ b/app/table-streams/synonyms/index.ts @@ -36,7 +36,15 @@ async function putIndex(synonymGroup: SynonymGroup) { }) } -export const handler = createTriggerHandler( +// Export handler entrypoint for instrumentation with OpenTelemetry. +// From https://aws-otel.github.io/docs/getting-started/lambda/lambda-js#requirements: +// +// > For TypeScript users, if you are using esbuild (either directly or through +// > tools such as the AWS CDK), you must export your handler function through +// > module.exports rather than with the export keyword! The AWS mananaged layer +// > for ADOT JavaScript needs to hot-patch your handler at runtime, but can't +// > because esbuild makes your handler immutable when using the export keyword. +module.exports.handler = createTriggerHandler( async ({ eventName, dynamodb }: DynamoDBRecord) => { if (!eventName || !dynamodb) return const { synonymId } = unmarshallTrigger(dynamodb!.NewImage) as Synonym diff --git a/build/email-incoming/circulars/config.arc b/build/email-incoming/circulars/config.arc new file mode 100644 index 000000000..d40a13b99 --- /dev/null +++ b/build/email-incoming/circulars/config.arc @@ -0,0 +1,2 @@ +@aws +tracing true diff --git a/build/email-incoming/support/config.arc b/build/email-incoming/support/config.arc new file mode 100644 index 000000000..d40a13b99 --- /dev/null +++ b/build/email-incoming/support/config.arc @@ -0,0 +1,2 @@ +@aws +tracing true diff --git a/build/scheduled/ads/config.arc b/build/scheduled/ads/config.arc index 58c01e214..a04fde02e 100644 --- a/build/scheduled/ads/config.arc +++ b/build/scheduled/ads/config.arc @@ -1,2 +1,3 @@ @aws timeout 900 +tracing true diff --git a/build/scheduled/circulars/config.arc b/build/scheduled/circulars/config.arc index c70ae3946..44d90db67 100644 --- a/build/scheduled/circulars/config.arc +++ b/build/scheduled/circulars/config.arc @@ -1,3 +1,4 @@ @aws timeout 900 memory 512 +tracing true diff --git a/build/table-streams/circulars/config.arc b/build/table-streams/circulars/config.arc new file mode 100644 index 000000000..d40a13b99 --- /dev/null +++ b/build/table-streams/circulars/config.arc @@ -0,0 +1,2 @@ +@aws +tracing true diff --git a/build/table-streams/synonyms/config.arc b/build/table-streams/synonyms/config.arc new file mode 100644 index 000000000..d40a13b99 --- /dev/null +++ b/build/table-streams/synonyms/config.arc @@ -0,0 +1,2 @@ +@aws +tracing true diff --git a/package-lock.json b/package-lock.json index 967ed4436..72d191aa8 100644 --- a/package-lock.json +++ b/package-lock.json @@ -78,6 +78,7 @@ "@babel/preset-typescript": "^7.23.3", "@gitlab/svgs": "^3.83.0", "@nasa-gcn/architect-plugin-search": "^1.4.0", + "@nasa-gcn/architect-plugin-tracing": "^1.1.0", "@nasa-gcn/eslint-config-gitignore": "^0.0.2", "@playwright/test": "^1.48.2", "@remix-run/dev": "~2.10.3", @@ -14716,6 +14717,16 @@ "node": ">=18" } }, + "node_modules/@nasa-gcn/architect-plugin-tracing": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@nasa-gcn/architect-plugin-tracing/-/architect-plugin-tracing-1.1.0.tgz", + "integrity": "sha512-+uLqqfqLYDSpjv22nXOFqX4Z/Fcqlob7ay5sY58COBVKx82jqFhQ5V5sAKpek9D6CoE9KLAQHfH6NdYr4/y5rA==", + "dev": true, + "license": "Apache-2.0", + "engines": { + "node": ">=18" + } + }, "node_modules/@nasa-gcn/dynamodb-autoincrement": { "version": "2.2.1", "resolved": "https://registry.npmjs.org/@nasa-gcn/dynamodb-autoincrement/-/dynamodb-autoincrement-2.2.1.tgz", diff --git a/package.json b/package.json index 103889d25..82eeb835e 100644 --- a/package.json +++ b/package.json @@ -96,6 +96,7 @@ "@babel/preset-typescript": "^7.23.3", "@gitlab/svgs": "^3.83.0", "@nasa-gcn/architect-plugin-search": "^1.4.0", + "@nasa-gcn/architect-plugin-tracing": "^1.1.0", "@nasa-gcn/eslint-config-gitignore": "^0.0.2", "@playwright/test": "^1.48.2", "@remix-run/dev": "~2.10.3",