Instrument with CommonJS

To instrument your CommonJS lambda we recommend the AWS Lambda Extension. You can also install the Node.js Serverless Tracer using these steps:
  1. To install the tracer, navigate to the directory where the package.json file resides.

    Run the following npm command:

    npm install appdynamics-lambda-tracer --save

    The command downloads the tracer dependency into a node_modules/ folder.

  2. Initialize the Node.js Serverless Tracer below the require statement, by calling the tracer.init method.
    tracer = require('appdynamics-lambda-tracer');
    //Initialize the tracer
    tracer.init();
  3. To complete instrumentation, call tracer.mainModule(module) as the last line of your code.

    The code snippet below demonstrates how to instrument a serverless function with the tracer:

    // Your AWS Lambda handler function code here, for example:
    exports.handler = async (event) => {
    // TODO implement
    const response = {
    statusCode: 200,
    body: JSON.stringify('Hello from Lambda!'),
    };
    return response;
    };
    //Complete the instrumentation
    tracer.mainModule(module);