Configuring the NodeJS Tracing Library

Cette page n'est pas encore disponible en français, sa traduction est en cours.
Si vous avez des questions ou des retours sur notre projet de traduction actuel, n'hésitez pas à nous contacter.

After you set up the tracing library with your code and configure the Agent to collect APM data, optionally configure the tracing library as desired, including setting up Unified Service Tagging.

Tracer settings can be configured with the following environment variables:


Set an application’s environment (for example, prod, pre-prod, and stage). Defaults to the environment configured in the Datadog Agent.
The service name used for this program. Defaults to the name field value in package.json.
The version number of the application. Defaults to the version field value in package.json.
Set global tags that are applied to all spans and runtime metrics. When passed as an environment variable, the format is key:value,key:value. When setting this programmatically, the format is tracer.init({ tags: { foo: 'bar' } }).

It is recommended that you use DD_ENV, DD_SERVICE, and DD_VERSION to set env, service, and version for your services. Review the Unified Service Tagging documentation for recommendations on configuring these environment variables.


Default: true
Whether to enable the tracer.
Default: false
Enable debug logging in the tracer.
Default: http://localhost:8126
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 apm_config.receiver_socket in your datadog.yaml file, or the DD_APM_RECEIVER_SOCKET environment variable.
Default: localhost
The address of the Agent that the tracer submits to.
Default: 8126
The port of the Trace Agent that the tracer submits to.
Default: 8125
The port of the DogStatsD Agent that metrics are submitted to.
Default: false
Enable automatic injection of trace IDs in logs for supported logging libraries.
Percentage of spans to sample as a float between 0 and 1. Defaults to the rates returned by the Datadog Agent.
Percentage of spans to sample as a float between 0 and 1. Defaults to 100 when DD_TRACE_SAMPLE_RATE is set. Otherwise, delegates rate limiting to the Datadog Agent.
A JSON array of objects. Each object must have a “sample_rate”, and the “name” and “service” fields are optional. The “sample_rate” value must be between 0.0 and 1.0 (inclusive). Rules are applied in configured order to determine the trace’s sample rate. If omitted, the tracer defers to the Agent to dynamically adjust sample rate across all traces.
Default: undefined
A JSON array of objects. Rules are applied in configured order to determine the span’s sample rate. The sample_rate value must be between 0.0 and 1.0 (inclusive). For more information, see Ingestion Mechanisms.
  • Set the span sample rate to 50% for the service my-service and operation name http.request, up to 50 traces per second: '[{"service": "my-service", "name": "http.request", "sample_rate":0.5, "max_per_second": 50}]'
Default: false
Whether to enable capturing runtime metrics. Port 8125 (or configured with DD_DOGSTATSD_PORT) must be opened on the Agent for UDP.
Example: mysql:my-mysql-service-name-db,pg:my-pg-service-name-db
Provide service names for each plugin. Accepts comma separated plugin:service-name pairs, with or without spaces.
A comma-separated string of integration names automatically disabled when the tracer is initialized. Environment variable only, for example, DD_TRACE_DISABLED_PLUGINS=express,dns.
Default: debug
A string for the minimum log level for the tracer to use when debug logging is enabled, for example, error, debug.

For more options including the programmatic configuration API, see the API documentation.

Further Reading