Serverless in Node.js

Use the installation instructions below if you're installing Helios in a Node.js serverless function.

AWS Lambda

Navigate to your project's root directory, and install the latest Helios OpenTelemetry SDK:

npm install --save @heliosphere/opentelemetry-sdk

Define the following environment variable in your Lambda configuration:

NODE_OPTIONS="--require @heliosphere/opentelemetry-sdk"
HS_TOKEN=<API_TOKEN> # TODO: Replace value with API token from Helios.
HS_SERVICE_NAME=<SERVICE_NAME> # TODO: Replace value with service name.
HS_ENVIRONMENT="<ENVIRONMENT_NAME>" # TODO: Replace value with service environment.


Wrap your Lambda handler function as demonstrated in the following example:

const { instrumentLambda } = require('@heliosphere/opentelemetry-sdk');

const originHandler = async (event) => {..} // The original Lambda handler

const handler = instrumentLambda(originHandler);

export default handler;

Define the following environment variables in your Lambda configuration:

HS_TOKEN=<API_TOKEN>,           // TODO: Insert API token from Helios.
HS_SERVICE_NAME=<SERVICE_NAME>, // TODO: Insert service name.
HS_ENVIRONMENT=<ENVIRONMENT>,   // Defaults to process.env.NODE_ENV if omitted.
HS_COMMIT_HASH=<COMMIT_HASH>,   // Defaults to process.env.COMMIT_HASH if omitted.


OpenTelemetry dynamic require

For node_modules that are not part of the webpack bundle (configured as external), OpenTelemetry instrumentation should seamlessly work.
In case those are bundled, instrumentations should also work (even though webpack might print warnings in the build process).


All set

After setup is complete and once the service is up and running, it will show up in the Helios application.


Learn more about instrumenting your webpack-bundled JS code

Check out this Helios blog post.

Did this page help you?