Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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
11 changes: 2 additions & 9 deletions aws-distro-opentelemetry-node-autoinstrumentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,7 @@
"repository": "aws-observability/aws-otel-js-instrumentation",
"scripts": {
"clean": "rimraf build/*",
"compile:tsc": "tsc -p .",
"compile:webpack": "webpack",
"compile": "npm run compile:webpack",
"compile": "tsc -p .",
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"create-version": "node -p \"'export const LIB_VERSION = ' + JSON.stringify(require('./package.json').version) + ';'\" > src/version.ts",
Expand Down Expand Up @@ -95,11 +93,8 @@
"proxyquire": "^2.1.3",
"rimraf": "5.0.5",
"sinon": "15.2.0",
"ts-loader": "^9.5.2",
"ts-mocha": "10.0.0",
"typescript": "4.4.4",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1"
"typescript": "4.4.4"
},
"dependencies": {
"@opentelemetry/api": "1.9.0",
Expand All @@ -115,7 +110,6 @@
"@opentelemetry/instrumentation-aws-sdk": "0.49.0",
"@opentelemetry/otlp-transformer": "0.57.1",
"@opentelemetry/propagator-aws-xray": "1.26.2",
"@opentelemetry/propagator-aws-xray-lambda": "^0.54.0",
"@opentelemetry/resource-detector-aws": "1.12.0",
"@opentelemetry/resources": "1.30.1",
"@opentelemetry/sdk-metrics": "1.30.1",
Expand All @@ -127,7 +121,6 @@
"build/src/**/*.js",
"build/src/**/*.js.map",
"build/src/**/*.d.ts",
"build/src/**/*.d.ts.map",
"build/src/**/*.json"
]
}

This file was deleted.

23 changes: 23 additions & 0 deletions lambda-layer/packages/layer/install-externals.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/bash

set -euf -o pipefail

# Space separated list of external NPM packages
EXTERNAL_PACKAGES=( "import-in-the-middle" )

for EXTERNAL_PACKAGE in "${EXTERNAL_PACKAGES[@]}"
do
echo "Installing external package $EXTERNAL_PACKAGE ..."

PACKAGE_VERSION=$(npm query "#$EXTERNAL_PACKAGE" \
| grep version \
| head -1 \
| awk -F: '{ print $2 }' \
| sed 's/[",]//g')

echo "Resolved version of the external package $EXTERNAL_PACKAGE: $PACKAGE_VERSION"

npm install "$EXTERNAL_PACKAGE@$PACKAGE_VERSION" --prefix ./build/workspace/nodejs --production --ignore-scripts

echo "Installed external package $EXTERNAL_PACKAGE"
done
9 changes: 7 additions & 2 deletions lambda-layer/packages/layer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"lint": "eslint . --ext .ts",
"lint:fix": "eslint . --ext .ts --fix",
"prepare": "npm run compile",
"compile": "tsc -p .",
"postcompile": "copyfiles -F 'node_modules/**' build/workspace/nodejs && copyfiles -f 'scripts/*' build/workspace && copyfiles -f 'build/src/*' build/workspace && cd build/workspace && bestzip ../layer.zip *"
"compile": "webpack && ./install-externals.sh",
"postcompile": "copyfiles -f 'scripts/*' build/workspace && copyfiles -f 'build/src/*' build/workspace && cd build/workspace && bestzip ../layer.zip *"
},
"keywords": [
"awsdistroopentelemetry",
Expand All @@ -34,5 +34,10 @@
],
"dependencies": {
"@aws/aws-distro-opentelemetry-node-autoinstrumentation": "file:../../../aws-distro-opentelemetry-node-autoinstrumentation/aws-aws-distro-opentelemetry-node-autoinstrumentation-0.5.0-dev0.tgz"
},
"devDependencies": {
"ts-loader": "^9.5.2",
"webpack": "^5.98.0",
"webpack-cli": "^6.0.1"
}
}
2 changes: 1 addition & 1 deletion lambda-layer/packages/layer/scripts/otel-instrument
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ _is_esm_handler() {
}

if _is_esm_handler || [[ ${HANDLER_IS_ESM} == true ]]; then
export NODE_OPTIONS="${NODE_OPTIONS} --import @aws/aws-distro-opentelemetry-node-autoinstrumentation/register --experimental-loader=@opentelemetry/instrumentation/hook.mjs"
export NODE_OPTIONS="${NODE_OPTIONS} --import /opt/wrapper.js --experimental-loader=import-in-the-middle/hook.mjs"
export HANDLER_IS_ESM=true
else
export NODE_OPTIONS="${NODE_OPTIONS} --require /opt/wrapper.js"
Expand Down
11 changes: 11 additions & 0 deletions lambda-layer/packages/layer/tsconfig.webpack.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"extends": "../../tsconfig.esm",
"compilerOptions": {
"rootDir": ".",
"outDir": "build",
},
"include": [
"src/**/*.ts",
"test/**/*.ts"
]
}
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
const path = require('path');

module.exports = {
entry: './src/register.ts',
entry: './src/wrapper.ts',
target: 'node',
mode: 'production',
externalsPresets: { node: true },
externals: [
'import-in-the-middle',
'@aws-sdk',
],
output: {
path: path.resolve('./build/src'),
filename: 'register.js',
filename: 'wrapper.js',
library: {
type: 'commonjs2',
}
Expand Down
27 changes: 27 additions & 0 deletions lambda-layer/tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"compilerOptions": {
"moduleResolution": "node",
"module": "es2020",
"target": "es2020",
"allowUnreachableCode": false,
"allowUnusedLabels": false,
"declaration": true,
"declarationMap": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"noEmitOnError": true,
"noFallthroughCasesInSwitch": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"pretty": true,
"sourceMap": true,
"strict": true,
"strictNullChecks": true,
"incremental": true,
"newLine": "LF"
},
"exclude": [
"node_modules"
]
}

Loading
Loading