Beginning in February 2020, AppDynamics switched from Semantic Versioning to Calendar Versioning for some agents and the first deployments of SaaS Controllers. In March 2020, the entire product suite will use Calendar Versioning.

Skip to end of metadata
Go to start of metadata

This topic provides requirements and an overview of the instrumentation process for Node.js functions.

Before You Begin

After you have subscribed to Serverless APM for AWS Lambda and set up your environment variables, you can begin instrumentation. Ensure that your setup meets the following requirements:

Download the Node.js Serverless Tracer

To install the tracer, navigate to the directory where the package.json file resides and run the following npm command:

npm install appdynamics-lambda-tracer --save

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

Add the Require Statement

To add the tracer to your application, add a require statement in your application code's primary file that includes the AWS Lambda handler function:

const tracer = require('appdynamics-lambda-tracer');

Remember to add the tracer's require statement before any other require statement. 

Instrument the Function with the Node.js Serverless Tracer

Initialize the Node.js Serverless Tracer below the require statement, by calling the tracer.init method.

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:

const tracer = require('appdynamics-lambda-tracer'); 
//Initialize 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

By default, the Node.js Serverless Tracer automatically discovers exit calls passed over HTTP or inter-AWS Lambda calls. You need to create an exit call if your function does not use these protocols. See Customize the Node.js Serverless Tracer.

Next Steps

You are now ready to Verify the Serverless Tracer Instrumentation

You can then Integrate the Node.js Serverless Tracer with End User Monitoring or Customize the Node.js Serverless Tracer

  • No labels