Node.js Auto-Instrumentation

Want to use OpenTelemetry instead? Read these docs to get started!

If your app is written in Node.js, you can get started quickly with Cloud Observability. Download the Auto-Installer, then configure it to communicate with your Cloud Observability Microsatellites. When you deploy your app, all supported libraries will send trace data to Cloud Observability.

To ensure you can access all Cloud Observability functionality, including infrastructure metrics reporting, update your tracer to the latest release. To update, simply follow the instructions for installing the tracer. No code changes are needed.

These Auto-Installers are forked from Datadog’s contribution of their tracers to the OpenTelemetry project. You can find the original Datadog docs here.

This library MUST be imported and initialized before any instrumented module. When using a transpiler, you MUST import and initialize the tracer library in an external file and then import that file as a whole when building your application. This prevents hoisting and ensures that the tracer library gets imported and initialized before importing any other instrumented module.

Supported Node Versions

Node >=8 is supported by this Auto-Installer. Only even versions like 8.x and 10.x are officially supported. Odd versions like 9.x and 11.x should work but are not officially supported.

Install the Auto-Installer

  1. Install the Node.js Auto-Installer, using npm.

     npm install --save ls-trace
  2. Import and initialize the Auto-Installer and set trace propagation to use B3 headers.

    Cloud Observability recommends using B3 headers for trace propagation as the default, especially on hybrid deployments, as it is the most widely supported header at this time.

     const tracer = require('ls-trace').init(
     	experimental: {
     	  b3: true
     // server.js
     import "./tracer"; // must come before importing any instrumented module.
     // tracer.js
     import tracer from "ls-trace";
     tracer.init(); // initialized in a different file to avoid hoisting.
     export default tracer;

Configure the Auto-Installer to Send Data to Cloud Observability

To send data from your system to Cloud Observability, you need to configure the Auto-Installer to:

  • Point to your Microsatellites
  • Send global tags required by Cloud Observability to ingest and display the data to you.

To configure the Auto-Installer:

Configure the Auto-Installer to point to the Cloud Observability Microsatellites by setting these environment variables. Use the right values, depending on if you are using on-premise, Cloud Observability public, or Developer Mode Satellites.

Start tabs

On-Premise Microsatellites

DD_TRACE_AGENT_URL=https://<Satellite host>:<Satellite port>

Public Microsatellites


Developer Mode


End code tabs

The host and port values for on-premise Microsatellites is your pool address, found in your configuration file.

When setting the environment variable DD_TRACE_GLOBAL_TAGS, the following variables must be included:

  • service_name:
    The name of the service from which spans originate. This tag allows Cloud Observability to accurately report on your services, with features such as the Service diagram and the Service Directory
  • access_token:
    The access token for the project the tracers report to. Cloud Observability Microsatellites need this token to accept and store span data from the tracer. Reports from clients with invalid or deactivated access tokens will be rejected on ingress.


Following are issues you may have after instrumentation, and how to resolve them.

Operation Names Aren’t Human Readable

Operation names in Cloud Observability are not clear or are very long and unhelpful.

This feature requires a Satellite upgrade to the June 2020 release.

This can happen because the auto-installer is getting the name from a parameter in Datadog that might not be appropriate for your language. You can set that parameter to different values to see if that results in better operation names.

You can use either the resource or the name parameter, or both.

Which to use (or if using the both, the order to use) depends on the language of the installer. Refer to the Datadog docs for more info.

To configure how the operation name is set, add the following parameter to your Microsatellite configuration:

  	  - resource
  	  - name

If you set both, the order of the values matters. Cloud Observability tries to extract a name from the first variable value. If one isn’t found, it looks for the second value and uses that.

What’s Auto-Instrumented

The following auto-instrumentation libraries are supported:


ModuleVersionsSupport TypeNotes
connect>=2Fully Supported 
express>=4Fully SupportedSupports Sails, Loopback, and more
fastify>=1Fully Supported 
graphql>=0.10Fully SupportedSupports Apollo Server and express-graphql
hapi>=2Fully Supported 
koa>=2Fully Supported 
paperplane>=2.3Fully SupportedNot supported in serverless-mode
restify>=3Fully Supported 

Native Modules

ModuleSupport Type
dnsFully Supported
httpFully Supported
httpsFully Supported
netFully Supported

Data Stores

ModuleVersionsSupport TypeNotes
cassandra-driver>=3Fully Supported 
elasticsearch>=10Fully SupportedSupports @elastic/elasticsearch versions >=5
ioredis>=2Fully Supported 
knex>=0.8Fully SupportedThis integration is only for context propagation
memcached>=2.2Fully Supported 
mongodb-core>=2Fully SupportedSupports Mongoose
mysql>=2Fully Supported 
mysql2>=1Fully Supported 
pg>=4Fully SupportedSupports pg-native when used with pg
redis>=0.12Fully Supported 
tedious>=1Fully SupportedSQL Server driver for mssql and sequelize


ModuleVersionsSupport TypeNotes
amqp10>=3Fully SupportedSupports AMQP 1.0 brokers (i.e. ActiveMQ, Apache Qpid)
amqplib>=0.5Fully SupportedSupports AMQP 0.9 brokers (i.e. RabbitMQ, Apache Qpid)
generic-pool>=2Fully Supported 
kafka-node Coming Soon 
rhea Coming Soon 

Promise Libraries

ModuleVersionsSupport Type
bluebird>=2Fully Supported
promise>=7Fully Supported
promise-js>=0.0.3Fully Supported
q>=1Fully Supported
when>=3Fully Supported


ModuleVersionsSupport Type
bunyan>=1Fully Supported
paperplane>=2.3.2Fully Supported
pino>=2Fully Supported
winston>=1Fully Supported

See also

Measure your instrumentation quality

Updated Mar 3, 2020