For descriptions of terminology used in APM, take a look at the official documentation.
For details about configuration and using the API, see Datadog’s API documentation.
For details about contributing, check out the development guide.
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();
// server.js import './tracer'; // must come before importing any instrumented module. // tracer.js import tracer from 'dd-trace'; tracer.init(); // initialized in a different file to avoid hoisting. export default tracer;
See the tracer settings for the list of initialization options.
Tracer settings can be configured as a parameter to the
init() method or as environment variables.
|enabled||Whether to enable the tracer.|
|debug||Enable debug logging in the tracer.|
|service||The service name to be used for this program.|
|url||The URL of the Trace Agent that the tracer submits to. Takes priority over hostname and port, if set. Supports Unix Domain Sockets in combination with the |
|hostname||The address of the Agent that the tracer submits to.|
|port||The port of the Trace Agent that the tracer submits to.|
|dogstatsd.port||The port of the DogStatsD Agent that metrics are submitted to.|
|env||Set an application’s environment e.g. |
|logInjection||Enable automatic injection of trace IDs in logs for supported logging libraries.|
|tags||Set global tags that should be applied to all spans and metrics. When passed as an environment variable, the format is |
|sampleRate||-||Percentage of spans to sample as a float between |
|flushInterval||-||Interval (in milliseconds) at which the tracer submits traces to the Agent.|
|runtimeMetrics||Whether to enable capturing runtime metrics. Port |
|reportHostname||Whether to report the system’s hostname for each trace. When disabled, the hostname of the Agent is used instead.|
|experimental||-||Experimental features can be enabled all at once using Boolean true or individually using key/value pairs. Contact support to learn more about the available experimental features.|
|plugins||-||Whether or not to enable automatic instrumentation of external libraries using the built-in plugins.|
|clientToken||Client token for browser tracing. Can be generated in Datadog in Integrations -> APIs.|
|logLevel||A string for the minimum log level for the tracer to use when debug logging is enabled, e.g. |
Configure your application level tracers to submit traces to a custom Agent hostname:
The NodeJS Tracing Module automatically looks for and initializes with the ENV variables
DD_AGENT_HOST=<HOSTNAME> DD_TRACE_AGENT_PORT=<PORT> node server
To use a different protocol such as UDS, specify the entire URL as a single ENV variable
DD_TRACE_AGENT_URL=unix:<SOCKET_PATH> node server
>=8 is supported by this library. 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.
Node 4 or Node 6 versions are supported by version 0.13 of the
dd-trace-js tracer. This version will be supported until April 30th, 2020, but no new feature will be added.
Note: The global policy is that the Datadog JS tracer supports (only for bug fixes) a Node version until 1 year after its release reached its end-of-life.
APM provides out-of-the-box instrumentation for many popular frameworks and libraries by using a plugin system. If you would like support for a module that is not listed, contact support to share a request.
For details about how to how to toggle and configure plugins, check out the API documentation.
|express||Fully supported||Supports Sails, Loopback, and more|
|graphql||Fully supported||Supports Apollo Server and express-graphql|
|paperplane||Fully supported||Not supported in serverless-mode|
|elasticsearch||Fully supported||Supports |
|knex||Fully supported||This integration is only for context propagation|
|mongodb-core||Fully supported||Supports Mongoose|
|pg||Fully supported||Supports |
|tedious||Fully supported||SQL Server driver for |
|amqp10||Fully supported||Supports AMQP 1.0 brokers (i.e. ActiveMQ, Apache Qpid)|
|amqplib||Fully supported||Supports AMQP 0.9 brokers (i.e. RabbitMQ, Apache Qpid)|
Additional helpful documentation, links, and articles: