Skip to content

Commit

Permalink
Upgrade OTEL to latest AWS Distro (#2147)
Browse files Browse the repository at this point in the history
* bump lambda layer for otel

* bump app-api packages

* match packages

* move back to deps

* bump packages in app-web and uploads

* try external

* a couple more external

* exclude in serverless. package size too large

* move to dev

* more from layer

* we need @opentelemetry/auto-instrumentations-node

* test autoinstrumentation

* add packages back

* remove unused deps
  • Loading branch information
mojotalantikite authored Jan 3, 2024
1 parent 63e45ca commit bd2aa57
Show file tree
Hide file tree
Showing 8 changed files with 447 additions and 1,094 deletions.
23 changes: 12 additions & 11 deletions services/app-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,17 +37,7 @@
"@aws-sdk/client-ssm": "^3.226.0",
"@aws-sdk/lib-storage": "^3.226.0",
"@launchdarkly/node-server-sdk": "8.1.1",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/core": "^1.9.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.1",
"@opentelemetry/id-generator-aws-xray": "^1.1.1",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/instrumentation-http": "^0.35.1",
"@opentelemetry/propagator-aws-xray": "^1.1.1",
"@opentelemetry/resources": "^1.9.1",
"@opentelemetry/sdk-trace-base": "^1.9.1",
"@opentelemetry/sdk-trace-node": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.9.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.45.1",
"apollo-server-core": "^3.11.1",
"apollo-server-lambda": "^3.5.0",
"archiver": "^6.0.1",
Expand All @@ -66,6 +56,17 @@
},
"devDependencies": {
"@graphql-tools/jest-transform": "^2.0.0",
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/core": "^1.18.1",
"@opentelemetry/resources": "^1.18.1",
"@opentelemetry/sdk-trace-base": "^1.18.1",
"@opentelemetry/sdk-trace-node": "^1.18.1",
"@opentelemetry/semantic-conventions": "^1.18.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.45.1",
"@opentelemetry/id-generator-aws-xray": "^1.2.1",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/instrumentation-http": "^0.45.1",
"@opentelemetry/propagator-aws-xray": "^1.3.1",
"@prisma/client": "^4.6",
"@types/archiver": "^6.0.2",
"@types/aws-lambda": "^8.10.83",
Expand Down
21 changes: 17 additions & 4 deletions services/app-api/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,19 @@ custom:
includeModules:
forceExclude:
- '@prisma/client'
- '@opentelemetry/resources'
- '@opentelemetry/sdk-trace-base'
- '@opentelemetry/sdk-trace-node'
- '@opentelemetry/semantic-conventions'
- '@opentelemetry/api'
- '@opentelemetry/core'
- '@opentelemetry/id-generator-aws-xray'
- '@opentelemetry/instrumentation'
- '@opentelemetry/instrumentation-http'
- '@opentelemetry/propagator-aws-xray'
- '@opentelemetry/auto-instrumentations-node'
- '@opentelemetry/exporter-metrics-otlp-http'
- '@opentelemetry/sdk-metrics'
nodeModulesRelativeDir: '../../'
packagerOptions:
lockFile: '../../yarn.lock'
Expand Down Expand Up @@ -77,7 +90,7 @@ provider:
restApiId: ${self:custom.appApiGatewayId}
restApiRootResourceId: ${self:custom.appApiGatewayRootResourceId}
layers:
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:1
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1
iam:
role:
path: ${ssm:/configuration/iam/path, "/"}
Expand Down Expand Up @@ -202,7 +215,7 @@ functions:
subnetIds: ${self:custom.privateSubnets}
layers:
- !Ref PrismaClientEngineLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:1
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1

migrate:
handler: src/handlers/postgres_migrate.main
Expand All @@ -213,7 +226,7 @@ functions:
subnetIds: ${self:custom.privateSubnets}
layers:
- !Ref PrismaClientMigrationLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:1
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1

zip_keys:
handler: src/handlers/bulk_download.main
Expand All @@ -230,7 +243,7 @@ functions:
events:
- schedule: cron(0 14 ? * MON-FRI *)
layers:
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:1
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1

resources:
Resources:
Expand Down
13 changes: 13 additions & 0 deletions services/app-api/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ module.exports = {
}),
'prisma',
'@prisma/client',
'@opentelemetry/core',
'@opentelemetry/sdk-trace-base',
'@opentelemetry/sdk-trace-node',
'@opentelemetry/resources',
'@opentelemetry/semantic-conventions',
'@opentelemetry/api',
'@opentelemetry/id-generator-aws-xray',
'@opentelemetry/instrumentation',
'@opentelemetry/instrumentation-http',
'@opentelemetry/propagator-aws-xray',
'@opentelemetry/auto-instrumentations-node',
'@opentelemetry/exporter-metrics-otlp-http',
'@opentelemetry/sdk-metrics',
],
devtool: 'source-map',
resolve: {
Expand Down
22 changes: 11 additions & 11 deletions services/app-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,17 @@
"@apollo/explorer": "^3.0.0",
"@cypress/code-coverage": "^3.10.0",
"@cypress/instrument-cra": "^1.4.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/auto-instrumentations-web": "^0.31.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.1",
"@opentelemetry/id-generator-aws-xray": "^1.1.1",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/instrumentation-document-load": "^0.31.0",
"@opentelemetry/instrumentation-fetch": "^0.35.1",
"@opentelemetry/propagator-aws-xray": "^1.1.1",
"@opentelemetry/resources": "^1.9.1",
"@opentelemetry/sdk-trace-web": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.9.1",
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/auto-instrumentations-web": "^0.34.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.45.1",
"@opentelemetry/id-generator-aws-xray": "^1.2.1",
"@opentelemetry/instrumentation": "^0.45.1",
"@opentelemetry/instrumentation-document-load": "^0.34.0",
"@opentelemetry/instrumentation-fetch": "^0.45.1",
"@opentelemetry/propagator-aws-xray": "^1.3.1",
"@opentelemetry/resources": "^1.18.1",
"@opentelemetry/sdk-trace-web": "^1.18.1",
"@opentelemetry/semantic-conventions": "^1.18.1",
"@tanstack/react-table": "^8.8.5",
"@trussworks/react-uswds": "^3.2.0",
"@types/path-browserify": "^1.0.0",
Expand Down
22 changes: 10 additions & 12 deletions services/uploads/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,16 @@
},
"dependencies": {
"@aws-sdk/client-s3": "^3.262.0",
"@opentelemetry/api": "^1.3.0",
"@opentelemetry/auto-instrumentations-node": "^0.36.3",
"@opentelemetry/exporter-metrics-otlp-http": "^0.35.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.35.1",
"@opentelemetry/id-generator-aws-xray": "^1.1.1",
"@opentelemetry/instrumentation": "^0.35.1",
"@opentelemetry/resources": "^1.9.1",
"@opentelemetry/sdk-metrics": "^1.9.1",
"@opentelemetry/sdk-node": "^0.35.1",
"@opentelemetry/sdk-trace-base": "^1.9.1",
"@opentelemetry/sdk-trace-node": "^1.9.1",
"@opentelemetry/semantic-conventions": "^1.9.1"
"@opentelemetry/api": "^1.6.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.45.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.45.1",
"@opentelemetry/id-generator-aws-xray": "^1.2.1",
"@opentelemetry/resources": "^1.18.1",
"@opentelemetry/sdk-metrics": "^1.18.1",
"@opentelemetry/sdk-node": "^0.45.1",
"@opentelemetry/sdk-trace-base": "^1.18.1",
"@opentelemetry/sdk-trace-node": "^1.18.1",
"@opentelemetry/semantic-conventions": "^1.18.1"
},
"devDependencies": {
"copy-webpack-plugin": "^11.0.0",
Expand Down
8 changes: 4 additions & 4 deletions services/uploads/serverless.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ functions:
ephemeralStorageSize: 1024
layers:
- !Ref ClamDefsLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:2
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1
environment:
stage: ${sls:stage}
CLAMAV_BUCKET_NAME: !Ref ClamDefsBucket
Expand All @@ -125,7 +125,7 @@ functions:
memorySize: 1024
layers:
- !Ref ClamDefsLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:2
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1
environment:
stage: ${sls:stage}
CLAMAV_BUCKET_NAME: !Ref ClamDefsBucket
Expand All @@ -140,7 +140,7 @@ functions:
maximumRetryAttempts: 0
layers:
- !Ref ClamDefsLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:2
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1
environment:
stage: ${sls:stage}
AUDIT_BUCKET_NAME: !Ref DocumentUploadsBucket
Expand All @@ -160,7 +160,7 @@ functions:
maximumRetryAttempts: 0
layers:
- !Ref ClamDefsLambdaLayer
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-9-1:2
- arn:aws:lambda:us-east-1:901920570463:layer:aws-otel-nodejs-amd64-ver-1-18-1:1
environment:
stage: ${sls:stage}
AUDIT_BUCKET_NAME: !Ref DocumentUploadsBucket
Expand Down
6 changes: 0 additions & 6 deletions services/uploads/src/lib/otel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import opentelemetry from '@opentelemetry/api'
import { NodeTracerProvider } from '@opentelemetry/sdk-trace-node'
import { SemanticResourceAttributes } from '@opentelemetry/semantic-conventions'
import { Resource } from '@opentelemetry/resources'
import { getNodeAutoInstrumentations } from '@opentelemetry/auto-instrumentations-node'
import { BatchSpanProcessor } from '@opentelemetry/sdk-trace-base'
import { AWSXRayIdGenerator } from '@opentelemetry/id-generator-aws-xray'
import { registerInstrumentations } from '@opentelemetry/instrumentation'
import { OTLPTraceExporter } from '@opentelemetry/exporter-trace-otlp-http'

import { OTLPMetricExporter } from '@opentelemetry/exporter-metrics-otlp-http'
Expand All @@ -17,10 +15,6 @@ import {
export function initTracer(serviceName: string, otelCollectorURL: string) {
console.info('-----Setting OTEL instrumentation-----')

registerInstrumentations({
instrumentations: [getNodeAutoInstrumentations()],
})

const resource = Resource.default().merge(
new Resource({
[SemanticResourceAttributes.SERVICE_NAME]: serviceName,
Expand Down
Loading

0 comments on commit bd2aa57

Please sign in to comment.