Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable OpenTelemetry tracing for all Lambdas except for web app #2675

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app.arc
Original file line number Diff line number Diff line change
Expand Up @@ -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
10 changes: 9 additions & 1 deletion app/email-incoming/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
13 changes: 9 additions & 4 deletions app/email-incoming/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 9 additions & 1 deletion app/scheduled/ads/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<number>()
for await (const entries of getAdsEntries()) {
Expand Down
10 changes: 9 additions & 1 deletion app/scheduled/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
10 changes: 9 additions & 1 deletion app/table-streams/circulars/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = []
Expand Down
10 changes: 9 additions & 1 deletion app/table-streams/synonyms/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions build/email-incoming/circulars/config.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@aws
tracing true
2 changes: 2 additions & 0 deletions build/email-incoming/support/config.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@aws
tracing true
1 change: 1 addition & 0 deletions build/scheduled/ads/config.arc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
@aws
timeout 900
tracing true
1 change: 1 addition & 0 deletions build/scheduled/circulars/config.arc
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@aws
timeout 900
memory 512
tracing true
2 changes: 2 additions & 0 deletions build/table-streams/circulars/config.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@aws
tracing true
2 changes: 2 additions & 0 deletions build/table-streams/synonyms/config.arc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
@aws
tracing true
11 changes: 11 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
Loading