question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

crash when using aws-lambda instrumentation

See original GitHub issue

I’ve been running into an exception where the JS auto-instrumentation attempts to load package.json from the base path of a lambda handler. Is there a way to customize the path from /var/task/src/handlers/my-function-name/package.json to a higher level /var/task/package.json or /opt/my-extension/package.json?

Copying the package.json into the expected locations causes the instrumentation to work as expected, it would just be painful for the project’s build process.

Setup:

  • AWS managed Lambda Layer for ADOT JavaScript SDK and ADOT Collector
  • OpenTelemetry JS v0.18.0
  • OpenTelemetry JS Contrib v0.20b0,
  • ADOT Collector for Lambda v0.9.1
  • Node 12 runtimes
  • Serverless framework builds and deploys

Exception:

2021-05-07T16:40:57.227Z undefined ERROR Uncaught Exception {"errorType":"Runtime.ImportModuleError",
"errorMessage":"Error: Cannot find module '/var/task/src/handlers/my-function-name/package.json'\n
Require stack:\n- /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/node/instrumentation.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/node/index.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/index.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/autoLoader.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/index.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/aws-lambda.js\n-
 /opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/index.js\n-
 /opt/wrapper.js\n-
 
 internal/preload","stack":["Runtime.ImportModuleError: Error: Cannot find module '/var/task/src/handlers/my-function-name/package.json'",
 "Require stack:","- /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/node/instrumentation.js","-
  /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/node/index.js","-
   /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/platform/index.js","-
    /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/autoLoader.js","-
     /opt/nodejs/node_modules/@opentelemetry/instrumentation/build/src/index.js","-
      /opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/aws-lambda.js","-
       /opt/nodejs/node_modules/@opentelemetry/instrumentation-aws-lambda/build/src/index.js","-
        /opt/wrapper.js","- internal/preload"," at _loadUserApp (/var/runtime/UserFunction.js:100:13)","
         at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)"," at Object.<anonymous> (/var/runtime/index.js:43:30)",
         " at Module._compile (internal/modules/cjs/loader.js:999:30)","
         at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)"," at Module.load (internal/modules/cjs/loader.js:863:32)","
          at Function.Module._load (internal/modules/cjs/loader.js:708:14)","
           at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)"," at internal/main/run_main_module.js:17:47"]}

_Originally posted by @adambartholomew in https://github.com/open-telemetry/opentelemetry-js/discussions/2192_

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:9
  • Comments:18 (14 by maintainers)

github_iconTop GitHub Comments

4reactions
dyladancommented, May 18, 2021

That’s what I was thinking. If the supportedVersions.contains('*') we shouldn’t have any reason to even attempt to find the package.json

1reaction
nozikcommented, Sep 9, 2021

@vmarchaud The PR was merged (https://github.com/open-telemetry/opentelemetry-js/pull/2450) - should we close the ticket?

Read more comments on GitHub >

github_iconTop Results From Across the Web

APM Serverless Lambda. Python extension crash. AWS...
Firstly, in case someone is trying to auto instrument this process; The extension must be unzipped into /opt/extensions/ not to /opt/ like ...
Read more >
How do I troubleshoot Lambda function failures? - AWS
To troubleshoot Lambda function failures, first determine what's causing the error by using one or more of the AWS services and features ...
Read more >
Instrument your AWS Lambda function for Splunk ...
The Splunk OpenTelemetry Lambda Layer automatically instruments your AWS Lambda functions for many programming languages. Follow these steps to get started.
Read more >
Monitoring AWS Lambda With Datadog
Learn how to use Datadog to collect metrics, traces, and logs from your AWS Lambda functions.
Read more >
Use nodejs lambda layer, npm package, or both? - APM
If you are including the APM agent it in your package.json and hence in the .zip file that is uploaded to AWS for...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found