tracer.init(). Environment variables take effect when the programmatic option is not set. Programmatic configuration always takes precedence over environment variables.
General
The service name for this application. If not set, dd-trace attempts to infer it from
package.json. In serverless environments it is inferred from the function name environment variable.Env: DD_SERVICE, OTEL_SERVICE_NAMEThe environment name (e.g.,
prod, staging, development). Appears as the env tag on all spans.Env: DD_ENVThe application version. If not set, dd-trace attempts to infer it from
package.json.Env: DD_VERSIONThe hostname of the Datadog Agent. Overridden by
url if both are set.Env: DD_AGENT_HOSTThe port of the Datadog Agent.Env:
DD_TRACE_AGENT_PORTThe full URL of the Datadog Agent (e.g.,
http://localhost:8126). Takes priority over hostname and port.Env: DD_TRACE_AGENT_URLGlobal tags applied to every span. Values are merged with Env:
DD_TAGS.DD_TAGS, OTEL_RESOURCE_ATTRIBUTESOverride the service name for specific integrations. Keys are plugin names, values are service names.Env:
DD_SERVICE_MAPPING (comma-separated key:value pairs)Whether to load all built-in plugins automatically. Set to
false to disable all auto-instrumentation and enable plugins manually with tracer.use().Env: (not configurable via environment variable)Custom logger instance. Must implement
error(), warn(), info(), and debug() methods. Used when DD_TRACE_DEBUG=true.Minimum log level when debug logging is enabled. One of
debug, info, warn, error.Env: DD_TRACE_LOG_LEVEL, OTEL_LOG_LEVELPrint tracer configuration to the console at startup.Env:
DD_TRACE_STARTUP_LOGSAttach the hostname of the service host to every span. Useful when the Agent is on a different host and cannot determine the hostname automatically.Env:
DD_TRACE_REPORT_HOSTNAMETrace Agent API protocol version. The version must be supported by the Agent installed.Env:
DD_TRACE_AGENT_PROTOCOL_VERSIONWhether to enable APM tracing. Set to
false when using standalone Datadog products (e.g., AppSec standalone mode) without APM.Env: DD_APM_TRACING_ENABLEDTracing
Interval in milliseconds at which the tracer submits traces to the Agent. In Lambda environments this is automatically set to
0 (flush synchronously).Env: DD_TRACE_FLUSH_INTERVALNumber of spans before partially exporting a trace. Prevents very large traces from being held entirely in memory.Env:
DD_TRACE_PARTIAL_FLUSH_MIN_SPANSContext propagation formats for injection and extraction. Accepts an array of format names (Env:
datadog, tracecontext, b3, b3 single header, none) or an object with separate inject and extract arrays.DD_TRACE_PROPAGATION_STYLE, DD_TRACE_PROPAGATION_STYLE_INJECT, DD_TRACE_PROPAGATION_STYLE_EXTRACTHTTP request headers to capture as span tags. Each entry is a header name; the tag name will be
http.request.headers.<name>.Env: DD_TRACE_HEADER_TAGSDatabase Monitoring to APM link mode. One of
disabled, service, or full.Env: DD_DBM_PROPAGATION_MODEWhether to enable Data Streams Monitoring.Env:
DD_DATA_STREAMS_ENABLEDCollect client IP from incoming request headers and tag spans with
http.client_ip.Env: DD_TRACE_CLIENT_IP_ENABLEDCustom header name from which to read the client IP. Takes precedence over automatic detection.Env:
DD_TRACE_CLIENT_IP_HEADERSampling
Global trace sample rate, between
0 (drop all) and 1 (keep all). When not set, the Agent determines the rate via priority sampling.Env: DD_TRACE_SAMPLE_RATE, OTEL_TRACES_SAMPLER, OTEL_TRACES_SAMPLER_ARGGlobal rate limit (traces per second) applied after sampling rules. Defaults to deferring the decision to the Agent.Env:
DD_TRACE_RATE_LIMITArray of sampling rules applied to priority sampling. Each rule specifies Env:
sampleRate and optionally service (string or regex) and name (string or regex).DD_TRACE_SAMPLING_RULES (JSON array)Span sampling rules that keep individual spans from dropped traces. Each rule specifies optional Env:
service, name, sampleRate (default 1.0), and maxPerSecond.DD_SPAN_SAMPLING_RULES, DD_SPAN_SAMPLING_RULES_FILELog injection
Inject
dd.trace_id, dd.span_id, dd.service, dd.env, and dd.version fields into log records automatically. Works with supported logging libraries (winston, bunyan, pino, etc.).Env: DD_LOGS_INJECTIONRuntime metrics
Enable runtime metrics collection. Can be a boolean or an object to control individual metric types:Env:
DD_RUNTIME_METRICS_ENABLED, DD_RUNTIME_METRICS_GC_ENABLED, DD_RUNTIME_METRICS_EVENT_LOOP_ENABLEDConfiguration for the DogStatsD agent that receives runtime metrics.
Profiling
Enable continuous profiling. Sends CPU, heap, and wall-time profiles to Datadog Profiling.Env:
DD_PROFILING_ENABLEDAppSec
Enable Application Security Monitoring. Can be a boolean or a configuration object:Env:
DD_APPSEC_ENABLEDIAST
Enable Interactive Application Security Testing. Can be a boolean or a configuration object. IAST detects code-level vulnerabilities at runtime.Env:
DD_IAST_ENABLEDRemote configuration
Configuration for Remote Config, which allows updating tracer settings without redeployment.Env:
DD_REMOTE_CONFIGURATION_ENABLED, DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDSCode origin for spans
Attach the source code location where a span was created to the span metadata.Env:
DD_CODE_ORIGIN_FOR_SPANS_ENABLEDCloud payload tagging
Tag cloud provider request/response payloads using JSONPath queries.Env:
DD_TRACE_CLOUD_REQUEST_PAYLOAD_TAGGING, DD_TRACE_CLOUD_RESPONSE_PAYLOAD_TAGGINGDynamic Instrumentation
Configuration for Dynamic Instrumentation (Live Debugging). Allows adding log probes and metric probes to running applications without redeployment.Env:
DD_DYNAMIC_INSTRUMENTATION_ENABLED, DD_DYNAMIC_INSTRUMENTATION_CAPTURE_TIMEOUT_MS, DD_DYNAMIC_INSTRUMENTATION_UPLOAD_INTERVAL_SECONDS, DD_DYNAMIC_INSTRUMENTATION_REDACTED_IDENTIFIERS, DD_DYNAMIC_INSTRUMENTATION_REDACTION_EXCLUDED_IDENTIFIERS, DD_DYNAMIC_INSTRUMENTATION_PROBE_FILERuntime metrics (additional)
Whether to add an auto-generated
runtime-id tag to runtime metrics. Useful for correlating metrics from the same process instance.Env: DD_RUNTIME_METRICS_RUNTIME_ID_ENABLEDDatabase Monitoring (DBM)
Advanced Database Monitoring configuration.Env:
DD_DBM_INJECT_SQL_BASEHASHinjectSqlBaseHash requires DD_EXPERIMENTAL_PROPAGATE_PROCESS_TAGS_ENABLED=true to take effect.Experimental options
Experimental features enabled individually. These may change or be removed without a major version bump.Env:
DD_TRACE_EXPERIMENTAL_EXPORTER, DD_TRACE_EXPERIMENTAL_GET_RUM_DATA_ENABLED, DD_TRACE_EXPERIMENTAL_B3_ENABLED