Instructions for installing the Lumigo tracer in a AWS Lambda function using a Node.js runtime

The @lumigo/tracer package is Lumigo's Node.js agent for distributed tracing and performance monitoring on AWS Lambda. It allows you to pursue automated metric gathering through Lambda Layers, automated metric gathering and instrumentation through the Serverless framework, or manual metric creation and implementation.

Supported AWS Lambda runtimes

  • 8.10
  • 10.x
  • 12.x
  • 14.x
  • 16.x


Add the Lumigo Tracer to your application

Install the @lumigo/tracer package using NPM:

$ npm i @lumigo/tracer

Next, wrap your handler in Lumigo's trace function.

const lumigo = require('@lumigo/tracer')()

const myHandler = async (event, context, callback) => { ... }

exports.handler = lumigo.trace(myHandler)

Connect Your Lumigo Account

Set your Lumigo token as the LUMIGO_TRACER_TOKEN environment variable of your Lambda function; refer to the Using AWS Lambda environment variables documentation for more information. Your Lumigo token is available in Settings -> Tracing -> Manual tracing.

We advise you to use the most secure available to you to store secrets such as your LUMIGO_TRACER_TOKEN; additionally, AWS provides integrations for AWS Key Management Service that keep the values of your Lambda environment variables secure.


@lumigo/tracer offers several different configuration options. Pass these to the Lambda function as environment variables:

  • LUMIGO_DEBUG=TRUE - Enables debug logging
  • LUMIGO_SECRET_MASKING_REGEX='["regex1", "regex2"]' - Prevents Lumigo from sending keys that match the supplied regular expressions. All regular expressions are case-insensitive. By default, Lumigo applies the following regular expressions:* [".pass.", ".key.", ".secret.", ".credential.", ".passphrase."].
  • LUMIGO_DOMAINS_SCRUBBER='[".secret."]' - Prevents Lumigo from collecting both request and response details from a list of domains. This accepts a comma-separated list of regular expressions that is JSON-formatted. By default, the tracer uses ["", "", ""]*. Note - These defaults are overridden when you define a different list of regular expressions.
  • LUMIGO_SWITCH_OFF=TRUE - In the event a critical issue arises, this turns off all actions that Lumigo takes in response to your code. This happens without a deployment, and is picked up on the next function run once the environment variable is present.

Library support



Supported versions




See the notes below











MongoDB and Webpack

Add the following to your webpack.config file:

externals: {
  mongodb: 'mongodb',


Do you need Lumigo to support a different package?

If Lumigo does not yet support a package you use, please contact our support.

Did this page help you?