serverless / dashboard

MIT License
26 stars 10 forks source link

AWS Lambda SDK: Ensure our `--require` option is first #696

Closed medikoo closed 1 year ago

medikoo commented 1 year ago

Some instrumentations (as Baselime: https://baselime.io/docs/sending-data/otel/) inject their instrumentation via NODE_OPTIONS=--require... instead of AWS_LAMBDA_EXEC_WRAPPER

Our instrumentation applies same method yet it's done via module pointed in AWS_LAMBDA_EXEC_WRAPPER env variable: https://github.com/serverless/console/blob/795bb111be87a6aa728a9b947f7b8de3c09f5581/node/packages/aws-lambda-sdk/internal-extension/exec-wrapper.sh#L3

We respect all other eventually set NODE_OPTIONS, so in case of Baselime it'll result with setting as --require <baseline module> --require <console module>.

As I tested Node.js respects input for all --require calls, and loads them in provided order, so that is not breaking for Baselime. Yet to ensure most correct instrumentation outcome it'll be better if our instrumentation is loaded first. This PR ensures that