From 59c82b13673a9f1b2a9bd2489d87c777484b9247 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rafa=C5=82=20Sumis=C5=82awski?= Date: Thu, 6 Jun 2024 23:13:00 +0200 Subject: [PATCH] Extract aws-user-function to separate module to resolve import issues --- ci-scripts/build_nodejs_layer.sh | 9 +++++++- .../Errors.js} | 0 .../index.d.ts} | 0 .../index.js} | 2 +- .../cx-aws-user-function/package-lock.json | 15 +++++++++++++ .../cx-aws-user-function/package.json | 22 +++++++++++++++++++ nodejs/packages/cx-wrapper/index.ts | 2 +- nodejs/packages/cx-wrapper/package-lock.json | 13 +++++++++++ nodejs/packages/cx-wrapper/package.json | 2 +- nodejs/packages/layer/package-lock.json | 12 +++++++++- nodejs/packages/layer/package.json | 1 + 11 files changed, 73 insertions(+), 5 deletions(-) rename nodejs/packages/{cx-wrapper/aws/Errors.cjs => cx-aws-user-function/Errors.js} (100%) rename nodejs/packages/{cx-wrapper/aws/aws-user-function.d.ts => cx-aws-user-function/index.d.ts} (100%) rename nodejs/packages/{cx-wrapper/aws/aws-user-function.cjs => cx-aws-user-function/index.js} (99%) create mode 100644 nodejs/packages/cx-aws-user-function/package-lock.json create mode 100644 nodejs/packages/cx-aws-user-function/package.json diff --git a/ci-scripts/build_nodejs_layer.sh b/ci-scripts/build_nodejs_layer.sh index 6e4d4557b1..a675b97faa 100755 --- a/ci-scripts/build_nodejs_layer.sh +++ b/ci-scripts/build_nodejs_layer.sh @@ -92,6 +92,11 @@ rm -f import-in-the-middle-*.tgz npm install && npm pack popd > /dev/null +pushd ./nodejs/packages/cx-aws-user-function +rm -f cx-aws-user-function-*.tgz +npm install && npm pack +popd > /dev/null + pushd ./nodejs/packages/cx-wrapper npm install \ ${OPENTELEMETRY_JS_CONTRIB_PATH}/plugins/node/opentelemetry-instrumentation-aws-lambda/opentelemetry-instrumentation-aws-lambda-*.tgz \ @@ -99,7 +104,8 @@ npm install \ ${OPENTELEMETRY_JS_CONTRIB_PATH}/plugins/node/opentelemetry-instrumentation-aws-sdk/opentelemetry-instrumentation-aws-sdk-*.tgz \ ${OPENTELEMETRY_JS_PATH}/experimental/packages/opentelemetry-instrumentation/opentelemetry-instrumentation-*.tgz \ ${OPENTELEMETRY_JS_PATH}/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-*.tgz \ - ${IITM_PATH}/import-in-the-middle-*.tgz + ${IITM_PATH}/import-in-the-middle-*.tgz \ + ${CWD}/nodejs/packages/cx-aws-user-function/cx-aws-user-function-*.tgz popd > /dev/null # Build import-in-the-middle @@ -117,6 +123,7 @@ npm install \ ${OPENTELEMETRY_JS_PATH}/experimental/packages/opentelemetry-instrumentation/opentelemetry-instrumentation-*.tgz \ ${OPENTELEMETRY_JS_PATH}/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-*.tgz \ ${IITM_PATH}/import-in-the-middle-*.tgz \ + ${CWD}/nodejs/packages/cx-aws-user-function/cx-aws-user-function-*.tgz \ ${CWD}/nodejs/packages/cx-wrapper/cx-wrapper-*.tgz popd > /dev/null diff --git a/nodejs/packages/cx-wrapper/aws/Errors.cjs b/nodejs/packages/cx-aws-user-function/Errors.js similarity index 100% rename from nodejs/packages/cx-wrapper/aws/Errors.cjs rename to nodejs/packages/cx-aws-user-function/Errors.js diff --git a/nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts b/nodejs/packages/cx-aws-user-function/index.d.ts similarity index 100% rename from nodejs/packages/cx-wrapper/aws/aws-user-function.d.ts rename to nodejs/packages/cx-aws-user-function/index.d.ts diff --git a/nodejs/packages/cx-wrapper/aws/aws-user-function.cjs b/nodejs/packages/cx-aws-user-function/index.js similarity index 99% rename from nodejs/packages/cx-wrapper/aws/aws-user-function.cjs rename to nodejs/packages/cx-aws-user-function/index.js index 3d78506aa4..9c448864bb 100644 --- a/nodejs/packages/cx-wrapper/aws/aws-user-function.cjs +++ b/nodejs/packages/cx-aws-user-function/index.js @@ -15,7 +15,7 @@ const { MalformedHandlerName, ImportModuleError, UserCodeSyntaxError -} = require("./Errors.cjs"); +} = require("./Errors.js"); const path = require("path"); const fs = require("fs"); const FUNCTION_EXPR = /^([^.]*)\.(.*)$/; diff --git a/nodejs/packages/cx-aws-user-function/package-lock.json b/nodejs/packages/cx-aws-user-function/package-lock.json new file mode 100644 index 0000000000..8b13c26850 --- /dev/null +++ b/nodejs/packages/cx-aws-user-function/package-lock.json @@ -0,0 +1,15 @@ +{ + "name": "cx-aws-user-function", + "version": "0.0.1", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "cx-aws-user-function", + "version": "0.0.1", + "engines": { + "node": ">=16.0.0" + } + } + } +} diff --git a/nodejs/packages/cx-aws-user-function/package.json b/nodejs/packages/cx-aws-user-function/package.json new file mode 100644 index 0000000000..e516a19152 --- /dev/null +++ b/nodejs/packages/cx-aws-user-function/package.json @@ -0,0 +1,22 @@ +{ + "name": "cx-aws-user-function", + "version": "0.0.1", + "private": true, + "description": "", + "repository": "", + "keywords": [ + "opentelemetry", + "awslambda", + "nodejs", + "tracing", + "profiling", + "instrumentation" + ], + "engines": { + "node": ">=16.0.0" + }, + "files": [ + "*.js", + "*.d.ts" + ] +} diff --git a/nodejs/packages/cx-wrapper/index.ts b/nodejs/packages/cx-wrapper/index.ts index 4431138407..7aa3754902 100644 --- a/nodejs/packages/cx-wrapper/index.ts +++ b/nodejs/packages/cx-wrapper/index.ts @@ -1,5 +1,5 @@ -import { load } from './aws/aws-user-function.js'; +import { load } from 'cx-aws-user-function'; import { Callback, Context, diff --git a/nodejs/packages/cx-wrapper/package-lock.json b/nodejs/packages/cx-wrapper/package-lock.json index 4074220324..7bfa8b57ef 100644 --- a/nodejs/packages/cx-wrapper/package-lock.json +++ b/nodejs/packages/cx-wrapper/package-lock.json @@ -34,6 +34,7 @@ "@opentelemetry/sdk-metrics": "1.22.0", "@opentelemetry/sdk-trace-base": "file:../../../../../oss/opentelemetry-js/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-1.22.0.tgz", "@opentelemetry/sdk-trace-node": "1.22.0", + "cx-aws-user-function": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", "import-in-the-middle": "file:../../../../import-in-the-middle/import-in-the-middle-1.7.3.tgz" }, "engines": { @@ -1170,6 +1171,14 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/cx-aws-user-function": { + "version": "0.0.1", + "resolved": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", + "integrity": "sha512-q3fd5Ny8BtZvJalp/M8+8nue739sqTF1WHaA4CI65Pl3irfUwv5TrxF8fj7OV+cDxB5kHNBTdAWFdwV6vwHXDg==", + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/debug": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", @@ -2386,6 +2395,10 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "cx-aws-user-function": { + "version": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", + "integrity": "sha512-q3fd5Ny8BtZvJalp/M8+8nue739sqTF1WHaA4CI65Pl3irfUwv5TrxF8fj7OV+cDxB5kHNBTdAWFdwV6vwHXDg==" + }, "debug": { "version": "4.3.5", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.5.tgz", diff --git a/nodejs/packages/cx-wrapper/package.json b/nodejs/packages/cx-wrapper/package.json index 6144895845..42c4fee44e 100644 --- a/nodejs/packages/cx-wrapper/package.json +++ b/nodejs/packages/cx-wrapper/package.json @@ -23,7 +23,6 @@ "node": ">=16.0.0" }, "files": [ - "aws/*", "*.js", "*.d.ts", "*.map", @@ -56,6 +55,7 @@ "@opentelemetry/sdk-metrics": "1.22.0", "@opentelemetry/sdk-trace-base": "file:../../../../../oss/opentelemetry-js/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-1.22.0.tgz", "@opentelemetry/sdk-trace-node": "1.22.0", + "cx-aws-user-function": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", "import-in-the-middle": "file:../../../../import-in-the-middle/import-in-the-middle-1.7.3.tgz" }, "overrides": { diff --git a/nodejs/packages/layer/package-lock.json b/nodejs/packages/layer/package-lock.json index e7475894b3..b0de24ce14 100644 --- a/nodejs/packages/layer/package-lock.json +++ b/nodejs/packages/layer/package-lock.json @@ -35,6 +35,7 @@ "@opentelemetry/sdk-metrics": "1.22.0", "@opentelemetry/sdk-trace-base": "file:../../../../../oss/opentelemetry-js/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-1.22.0.tgz", "@opentelemetry/sdk-trace-node": "1.22.0", + "cx-aws-user-function": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", "cx-wrapper": "file:../cx-wrapper/cx-wrapper-0.0.1.tgz", "import-in-the-middle": "file:../../../../import-in-the-middle/import-in-the-middle-1.7.3.tgz" }, @@ -1147,10 +1148,18 @@ "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" }, + "node_modules/cx-aws-user-function": { + "version": "0.0.1", + "resolved": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", + "integrity": "sha512-q3fd5Ny8BtZvJalp/M8+8nue739sqTF1WHaA4CI65Pl3irfUwv5TrxF8fj7OV+cDxB5kHNBTdAWFdwV6vwHXDg==", + "engines": { + "node": ">=16.0.0" + } + }, "node_modules/cx-wrapper": { "version": "0.0.1", "resolved": "file:../cx-wrapper/cx-wrapper-0.0.1.tgz", - "integrity": "sha512-ZDfT/+t82zqy4O/JTbwa+g604Zn0nXXNIDldd6l2ZWSk5BCZvUu8RO6Oo4hyyrdqQDjHCKDYkyweB5UQ2NkLxQ==", + "integrity": "sha512-0WaSEyDtiRwARcGk7aNQFnOXJd4Y0DYYNuxoYpgHTuccgVTjqqf1UitaISjI7VQFJgGJE28eg8gI0VSJ++ExHA==", "dependencies": { "@opentelemetry/api": "^1.7.0", "@opentelemetry/core": "1.22.0", @@ -1178,6 +1187,7 @@ "@opentelemetry/sdk-metrics": "1.22.0", "@opentelemetry/sdk-trace-base": "file:../../../../../oss/opentelemetry-js/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-1.22.0.tgz", "@opentelemetry/sdk-trace-node": "1.22.0", + "cx-aws-user-function": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", "import-in-the-middle": "file:../../../../import-in-the-middle/import-in-the-middle-1.7.3.tgz" }, "engines": { diff --git a/nodejs/packages/layer/package.json b/nodejs/packages/layer/package.json index e214886379..28af11acea 100644 --- a/nodejs/packages/layer/package.json +++ b/nodejs/packages/layer/package.json @@ -52,6 +52,7 @@ "@opentelemetry/sdk-metrics": "1.22.0", "@opentelemetry/sdk-trace-base": "file:../../../../../oss/opentelemetry-js/packages/opentelemetry-sdk-trace-base/opentelemetry-sdk-trace-base-1.22.0.tgz", "@opentelemetry/sdk-trace-node": "1.22.0", + "cx-aws-user-function": "file:../cx-aws-user-function/cx-aws-user-function-0.0.1.tgz", "cx-wrapper": "file:../cx-wrapper/cx-wrapper-0.0.1.tgz", "import-in-the-middle": "file:../../../../import-in-the-middle/import-in-the-middle-1.7.3.tgz" },