Instrument your Node.js application on a host

Follow the instructions on this page to instrument your Node.js application running on a host, such as a macOS, Windows, or Linux device. Make sure you have already installed the Observe Agent.

  1. Add the OpenTelemetry zero-code instrumentation for Node.js.

    Run the following commands to add zero-code instrumentation for your Node.js application, meaning you don’t have to modify your application’s source code to collect telemetry:

npm install --save @opentelemetry/api
npm install --save @opentelemetry/auto-instrumentations-node
  1. Configure the Node.js instrumentation. Set the following environment variables. Replace ${YOUR_SERVICE_NAME} with the name of your app or service.

export OTEL_SERVICE_NAME=${YOUR_SERVICE_NAME}
export NODE_OPTIONS="--require @opentelemetry/auto-instrumentations-node/register"
  1. Run your instrumented app:

node app.js