Node.js lambda
  • 06 Jan 2023
  • 2 Minutes to read
  • PDF

Node.js lambda

  • PDF

Article Summary

If you are using Node.js lambdas in your application, Traceable provides a tracing agent for you. Configuring Traceable for your application using Node.js lambda consists of deploying a lambda, adding the Traceable Node.js, and Traceable collector layers. The final step is to configure the Traceable Node.js and Traceable collector layers. A high-level deployment architecture for Traceable's Node.js lambda is shown in the following diagram.

The deployment at a high-level divided into three parts:

  1. Deploy a lambda
  2. Add the Traceable node and Traceable collector layers
  3. Configure Traceable node and Traceable collector layers

Before you begin

Make a note of the following points before you begin installation and configuration:

  • Make sure that you have installed and configured Traceable Platform agent. For more information, see Platform agent.
  • Make sure that the port number 4318 is available to the lambda function.
  • Make a note of the Traceable Platform agent IP address. It will be used in step 3 during configuration of layers.
  • Make sure that you have an AWS account.

Step 1 – Deploy a lambda

To deploy a lambda, make sure to first find or create a lambda for Node.js 10.x, 12.x or 14.x lambda. The lambda must have an API gateway as the frontend. 

The lambda must be using x86_64 architecture. Arm64 is currently not supported.

Step 2 – Add the layers

As part of adding layers, you need to add two layers to the Lambda. 

  • Layer 1 – ⁣traceableai-nodejs - This layer works for any version of Node.js supported in Lambda 10.x, 12.x, and 14.x.
  • Layer 2 – ⁣traceableai-collector
    LayerLatest Layer Version

In Lambda UI, when you add a layer, select Specify an ARN as shown below:

For detailed steps to add a layer, see Add the layers.

In the Specify an ARN section, use the following ARNs:

  • Node.js ARN – Select the ARN based on the region:
    • arn:aws:lambda:<aws-region>:031394183954:layer:traceableai-nodejs:8
  • Collector ARN – Select the ARN based on the region:
    • arn:aws:lambda:<aws-region>:031394183954:layer:traceableai-collector:5

Replace <aws-region> with the region your lambda is in, for example, us-east-1

Before proceeding to configuring layers, make sure that Lambda has the following:

  • traceableai-nodejs
  • traceableai-collector

Step 3 – Configure the layers

As part of configuring layers, you would have to configure Node.js and Collector layers. 

Configure collector layer

To configure the collector layer, configure the Traceable Platform agent endpoint by configuring TPA_ENDPOINT environment variable.

  • Configure TPA_ENDPOINT: http://<insert_your_tpa_ip>:4318 as an environment variable; tpa is the Traceable Platform agent IP address that you made a note of in the Before you begin section.
  • Make sure that the port number is 4318. This is important to connect to the Traceable Platform agent OTLP HTTP endpoint. 

Configure Node.js layer

To configure Node.js layers, set AWS_LAMBDA_EXEC_WRAPPER: /opt/traceableai-instrument environment variable on the lambda. This instructs the lambda to invoke Traceable's wrapper script instead of the default lambda handler. Traceable in turn invokes your original handler.


To verify a successful configuration of python lambda, invoke the lambda function by sending traffic through the API gateway endpoint. Login to Traceable platform and check whether the service and associated traces and spans are displayed. 


Following are a few troubleshooting tips for the python lambda deployment:

Troubleshooting tip
No data is reported
Set the TA_LOG_LEVEL=DEBUG environment variable in the lambda. Reinvoke the lambda and view the logs in cloudwatch for any errors that could help to determine the root cause.
The response body is not capturedCheck if the lambda returns a “Content-Type” header, that is set to a value including: application/json. If not, then update the lambda to return a content-type header.
The request body is not captured
Check if the incoming request is sending a “Content-Type” header, that is set to a value including: application/json? If not, then update the request to include a content-type header.
The status code is not reported
Check whether the lambda returns a statusCode field to indicate the HTTP status code?
If not, then update the lambda to return a statusCode field.

Was this article helpful?

What's Next