This topic provides requirements and an overview of the instrumentation process for Node.js functions.
Before You Begin
- Existing AWS Lambda functions built with Node.js version 8 and later
- Active Serverless APM for AWS Lambda subscription
- AppDynamics SaaS Controller version 4.5.11 or later
Download the Node.js Serverless Tracer
To install the tracer, navigate to the directory where the
package.json file resides and run the following
The command downloads the tracer dependency into a
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
Remember to add the tracer's
require statement before any other
Instrument the Function with the Node.js Serverless Tracer
Initialize the Node.js Serverless Tracer below the
require statement, by calling the
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:
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.
You are now ready to Verify the Serverless Tracer Instrumentation.