Skip to main content
This guide covers Node.js applications running on ECS, EC2, Kubernetes, or any container/VM environment. For AWS Lambda, see the Node.js Lambda guide.

1. Install the OpenTelemetry SDK

2. Enable Auto Instrumentation

Enable auto instrumentation by requiring the auto-instrumentations-node module using the --require flag:

3. Set Environment Variables

Add these environment variables to your service. Replace YOUR_TRACE0_ENV_API_KEY with the API key from your Trace0 environment.

4. Add Logger

To correlate logs with traces in Trace0, your application must use an OpenTelemetry-supported logger. We recommend using Pino, a low overhead JavaScript logger for Node.js. The instructions below use Pino, but the same approach applies to other supported loggers such as Winston. First, install the library:
Then create a logger.js file:
Finally, use the logger in your app:
All logs will now be exported to the Trace0 ingest endpoint.

5. Kubernetes Setup

If your application runs on Kubernetes, including Amazon EKS, Google Kubernetes Engine or Azure Kubernetes Service, add the following environment variables to your container specification.

6. Deploy Service

Deploy your service and watch traces, metrics, and logs appear in the Trace0 dashboard within seconds.

Example Service

See our example apps for working Node.js services with Trace0 installed: