Star us on GitHub
Star
Menu

AWS Lambda Node.JS Error Monitoring

Learn how to set up highlight.io on AWS Lambda.
1
Add `tracingOrigins` to your client Highlight snippet.

This backend SDK requires one of the Highlight frontend SDKs to be installed, so please make sure you've followed the fullstack mapping guide first.

H.init("<YOUR_PROJECT_ID>", { tracingOrigins: ['localhost', 'example.myapp.com/backend'], networkRecording: { enabled: true, recordHeadersAndBody: true, }, });
Copy
2
Install the relevant Highlight SDK(s).

Install @highlight-run/node with your package manager.

npm install --save @highlight-run/node
Copy
3
Initialize the Highlight JS SDK.

Initialize the Highlight JS SDK with your project ID.

import { H } from '@highlight-run/node' H.init({ projectID: '<YOUR_PROJECT_ID>', serviceName: '<YOUR_SERVICE_NAME>', environment: 'production', })
Copy
4
Add the AWS Lambda Node.js Highlight integration.

Use the Node Highlight SDK in your response handler.

import type { APIGatewayEvent } from 'aws-lambda' import { H, Handlers } from '@highlight-run/node' // setup console log recording H.init({ projectID: '<YOUR_PROJECT_ID>' }) // wrap your lambda with an error handler export const handler = Handlers.serverlessFunction( (event?: APIGatewayEvent) => { console.log('hello, world!', {queryString: event?.queryStringParameters}); return {statusCode: 200}; }, { projectID: '<YOUR_PROJECT_ID>', serviceName: 'my-lambda-function', serviceVersion: 'git-sha', environment: 'production', }, )
Copy
5
Verify that your SDK is reporting errors.

You'll want to throw an exception in one of your AWS Lambda handlers. Access the API handler and make sure the error shows up in Highlight.

6
Set up logging.

With the JS SDKs, your logs are reported automatically from console methods. See the JS logging setup guide for more details.