Lumigo Docs

Node.JS

Instructions for installing the Lumigo tracer in a Node.js environment

Install the Lumigo tracer

Start by installing the @lumigo/tracer NPM package from the command line:

npm install @lumigo/tracer --save

Update your Lambda Function Code

Next, add the Lumigo tracer to your Lambda function handler’s file, before the handler declaration. Use your Lumigo token which can be found in the Onboarding Page. You can use the following code as an example:

const lumigo = require('@lumigo/tracer')({ token: 'YOUR TOKEN HERE' })

Wrap the handler function:

Finally, we need to wrap the handler function in order to send trace events. There are two different ways to wrap a handler function:

Example 1:

This method wraps the function handler definition in lumigo.trace synchronously. Given the following sample code:

// before wrapping
module.exports.<HANDLER_NAME> = (event, context, callback) => {
  ... 
};

The wrapped function would look like the following

// after wrapping
module.exports.<HANDLER_NAME> = lumigo.trace((event, context, callback) => {
 ...
});

Example 2:

This method wraps the function handler, preserving its asynchronous nature. Given the following sample code:

// before wrapping
exports.<HANDLER_NAME> = async (event, context) => {
  ...
};

The wrapped function would look like the following

// after wrapping
exports.<HANDLER_NAME> = lumigo.trace(async (event, context) => {
 ...
});

📘

Using Lambda Layers?

You can find our Node.JS Lambda Layer here.

Learn more about Lambda Layers

Updated 8 months ago


Node.JS


Instructions for installing the Lumigo tracer in a Node.js environment

Suggested Edits are limited on API Reference Pages

You can only suggest edits to Markdown body content, but not to the API spec.