The Service Map for APM is here!

Tracing Node.js Applications

Getting Started

For descriptions of terminology used in APM, take a look at the official documentation.

For details about configuration and using the API, check out our API documentation.

For details about contributing, check out the development guide.

Requirements

Node ^4.7, ^6.9 and >=8 are supported by this library. However, it benefits significantly from the performance improvements introduced in Node >=8.3.

Installation

To begin tracing Node.js applications, first install and configure the Datadog Agent (see additional documentation for tracing Docker applications).

Next, install the Datadog Tracing library using npm:

npm install --save dd-trace

Finally, import and initialize the tracer:

// This line must come before importing any instrumented module.
const tracer = require('dd-trace').init()

See the tracer settings for the list of initialization options.

Note: The tracer must be initialized before importing any instrumented module.

Manual Instrumentation

If you aren’t using supported library instrumentation (see Compatibility), you may want to manually instrument your code.

The following example initializes a Datadog Tracer and creates a Span called web.request:

const tracer = require('dd-trace').init()
const span = tracer.startSpan('web.request')

span.setTag('http.url', '/login')
span.finish()

For more information on manual instrumentation, check out the API documentation.

Tracer Settings

Debug Mode

Debug mode is disabled by default, to enable it:

const tracer = require('dd-trace').init({
  debug: true
})

For more tracer settings, check out the API documentation.

Distributed Tracing

Distributed tracing allows you to propagate a single trace across multiple services, so you can see performance end-to-end.

Distributed tracing is enabled by default for all supported integrations.

Integrations

APM provides out-of-the-box instrumentation for many popular frameworks and libraries by using a plugin system.

For details about how to how to toggle and configure plugins, check out the API documentation.

Compatibility

The dd-trace library includes support for a number of modules. If you would like support for a module that is not listed, contact support to share a request.

Web Frameworks

Module Versions Support Type
express 4.x Fully Supported
graphql 0.13.x Fully Supported
hapi Coming Soon
koa Coming Soon
restify Coming Soon

Native Modules

Module Support Type
http Fully Supported
https Fully Supported

Data Stores

Module Versions Support Type
elasticsearch 15.x Fully Supported
mongodb-core 3.x Fully Supported
mysql 2.x Fully Supported
mysql2 ^1.5 Fully Supported
pg 6.x Fully Supported
redis ^2.6 Fully Supported
cassandra-driver Coming Soon
ioredis Coming Soon
memcached Coming Soon

Workers

Module Versions Support Type
amqplib* 0.5.x Fully Supported
kafka-node Coming Soon

Note: amqplib supports several message brokers including RabbitMQ and ActiveMQ.

Further Reading