For AI agents: A markdown version of this page is available at https://docs.datadoghq.com/tracing/trace_collection/library_config/cpp.md. A documentation index is available at /llms.txt.

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

To verify your runtime configuration and confirm settings, view the current configuration of your service in Datadog. Navigate to the APM Service Page, click Service Config, and select the SDK Configuration tab.

It is recommended to use DD_SERVICE, DD_ENV, and DD_VERSION to set env, service and version for your services. Refer to the Unified Service Tagging documentation for recommendations on which value to set for environment variables.

To configure the SDK using environment variables, set the variables before launching the instrumented application.

Configuration keys

35 configuration keys available for this library.

General Settings

(7)

Top-level Datadog configuration: API keys, service identity, Agent connection, intake site, hostname, global tags, and proxy settings.

DD_AGENT_HOST
Type: string
Default: localhost
Aliases:DD_TRACE_AGENT_HOSTNAME
The host name to use to connect the Datadog agent for traces. The host name can be IPv4, IPv6, or a domain name. If DD_TRACE_AGENT_URL is specified, the value of DD_AGENT_HOST is ignored.
DD_APM_TRACING_ENABLED
Type: boolean
Default: true
Aliases:DD_TRACING_ENABLED
Enables or disables sending APM trace data. When disabled, tracing still runs to support other products, but only periodic heartbeat traces and manually kept traces are sent.
DD_ENV
Type: string
Sets the global env tag applied to all telemetry emitted by the tracer (traces, metrics, logs, profiles). Use it to separate environments such as prod, staging, or dev.
DD_EXTERNAL_ENV
Type: string
Sets an external environment identifier attached to emitted telemetry for origin and environment attribution.
DD_SERVICE
Type: string
Sets the service name for your application.
DD_TAGS
Type: map
Custom tags applied to traces, profiles, and metrics, provided as comma-separated key:value pairs (for example, layer:api,team:intake).
DD_VERSION
Type: string

Sets the application’s version, used as the version tag in traces and logs (for example: 1.2.3, 6c44da20, 2020.02.13).

Language-specific notes:

  • PHP: starting with version 0.90.0, changes made at runtime through ini_set('datadog.version', ...) are also applied to the current root span.

Tracing Core

(8)

Core distributed tracing engine: Agent connection, trace and span ID generation, span lifecycle management, peer service mapping, resource normalization, query string obfuscation, and DB client configuration.

DD_TRACE_128_BIT_TRACEID_GENERATION_ENABLED
Type: boolean
Default: true
Controls whether the tracer generates 128-bit W3C trace IDs (32-character hex) or 64-bit Datadog trace IDs (16-character hex). 128-bit IDs are required for full W3C traceparent interoperability.
DD_TRACE_AGENT_PORT
Type: int
Default: 8126
The port of the Trace Agent that the tracer submits to. If the Agent configuration sets receiver_port or DD_APM_RECEIVER_PORT to something other than the default 8126, then DD_TRACE_AGENT_PORT or DD_TRACE_AGENT_URL must match it.
DD_TRACE_AGENT_URL
Type: string
Aliases:DD_TRACE_URL
Sets the URL endpoint where traces are sent. Overrides DD_AGENT_HOST and DD_TRACE_AGENT_PORT if set. Defaults to http://<DD_AGENT_HOST>:<DD_TRACE_AGENT_PORT> .
DD_TRACE_ENABLED
Type: boolean
Default: true
Aliases:DD_TRACING_ENABLED
Enable framework and library instrumentation. When false, the application code doesn’t generate any traces. See also DD_APM_TRACING_ENABLED.
DD_TRACE_REPORT_HOSTNAME
Type: boolean
Default: false
Whether to report the system’s hostname for each trace. When disabled, the hostname of the Agent is used instead.
DD_TRACE_RESOURCE_RENAMING_ALWAYS_SIMPLIFIED_ENDPOINT
Type: boolean
Default: false
Since: v2.1.0
When enabled, always sets the http.endpoint tag to the result of the Resource Renaming simplification algorithm, even when an explicit endpoint is available.
DD_TRACE_RESOURCE_RENAMING_ENABLED
Type: boolean
Default: false
Since: v2.1.0
Controls whether the http.endpoint tag is computed and added for incoming HTTP requests. This is disabled by default unless application security is enabled at startup, and can be explicitly enabled or disabled with this setting.
DD_TRACE_TAGS_PROPAGATION_MAX_LENGTH
Type: int
Default: 512
Maximum size in bytes for the serialized x-datadog-tags header when injecting trace context for propagation. If the encoded tags exceed this limit, the header is not written and a propagation error tag is set.

Trace Sampling

(5)

Sampling rules and rates that determine which traces and spans are kept or dropped, including per-service rules, rate limiting, and priority sampling.

DD_SPAN_SAMPLING_RULES
Type: array
Default: []
Span sampling rules to keep individual spans when the rest of the trace would otherwise be dropped. 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. Example: - 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}].
DD_SPAN_SAMPLING_RULES_FILE
Type: string
Points to a JSON file that contains the span sampling rules. DD_SPAN_SAMPLING_RULES takes precedence over this variable. See DD_SPAN_SAMPLING_RULES for the rule format.
DD_TRACE_RATE_LIMIT
Type: int
Default: 100
Sets the maximum number of traces to sample per second; applies only when either DD_TRACE_SAMPLING_RULES or DD_TRACE_SAMPLE_RATE is set.
DD_TRACE_SAMPLE_RATE
Type: decimal
Default: 1
Controls the ingestion sample rate (between 0.0 and 1.0) between the Agent and the backend.
DD_TRACE_SAMPLING_RULES
Type: array
Default: []
Configures custom sampling rules for traces. Rules are evaluated in order, and the first matching rule determines the sampling rate. If no rules match, the default sampling rate is used. For more information about how these configurations affect trace ingestion, see Ingestion Mechanisms.

Trace Propagation

(7)

Distributed trace context propagation, extraction and injection behavior, baggage handling, header tagging, HTTP client and server configuration, and SQL comment injection for Database Monitoring.

DD_PROPAGATION_STYLE_EXTRACT
Type: array
Default: datadog,tracecontext,baggage
A comma-separated list of header formats from which to attempt to extract distributed tracing propagation data. The first format found with complete and valid headers is used to define the trace to continue. Doesn’t apply if DD_TRACE_PROPAGATION_STYLE_EXTRACT is set.
DD_PROPAGATION_STYLE_INJECT
Type: array
Default: datadog,tracecontext,baggage
A comma-separated list of header formats to include to propagate distributed traces between services. The first format found with complete and valid headers is used to define the trace to continue. Doesn’t apply if DD_TRACE_PROPAGATION_STYLE_INJECT is set.
DD_TRACE_BAGGAGE_MAX_BYTES
Type: int
Default: 8192
Configuration key to set the maximum number of bytes that can be injected into the baggage header when propagating to a downstream service. Default value is 8192 bytes.
DD_TRACE_BAGGAGE_MAX_ITEMS
Type: int
Default: 64
Configuration key to set the maximum number of items that can be injected into the baggage header when propagating to a downstream service. Default value is 64 items.
DD_TRACE_PROPAGATION_STYLE
Type: array
Default: datadog,tracecontext,baggage
Aliases:OTEL_PROPAGATORS
A comma-separated list of header formats from which to attempt to inject and extract distributed tracing propagation data. The first format found with complete and valid headers is used to define the trace to continue. The more specific DD_TRACE_PROPAGATION_STYLE_INJECT and DD_TRACE_PROPAGATION_STYLE_EXTRACT configurations take priority when present.
DD_TRACE_PROPAGATION_STYLE_EXTRACT
Type: array
Default: datadog,tracecontext,baggage
Aliases:DD_PROPAGATION_STYLE_EXTRACT, DD_TRACE_PROPAGATION_STYLE
A comma-separated list of header formats from which to attempt to extract distributed tracing propagation data. The first format found with complete and valid headers is used to define the trace to continue.
DD_TRACE_PROPAGATION_STYLE_INJECT
Type: array
Default: datadog,tracecontext,baggage
Aliases:DD_PROPAGATION_STYLE_INJECT, DD_TRACE_PROPAGATION_STYLE
A comma-separated list of header formats to include to propagate distributed traces between services. The first format found with complete and valid headers is used to define the trace to continue.

Trace Logging

(2)

Tracer log output settings: log levels, log file paths, log rotation, and startup diagnostics.

DD_TRACE_DEBUG
Type: boolean
Default: false
Aliases:OTEL_LOG_LEVEL

Enables debug mode for the SDK. When set, the SDK emits verbose log messages for troubleshooting. Takes precedence over DD_TRACE_LOG_LEVEL when active. Use OTEL_LOG_LEVEL as an alias.

Language-specific notes:

  • PHP: log messages are written to the device or file set in the PHP error_log INI setting. The actual value may differ from php -i output because it can be overridden in PHP-FPM/Apache configuration files.
DD_TRACE_STARTUP_LOGS
Type: boolean
Default: true
Enables emission of startup configuration and diagnostic log lines when the tracer initializes.

Instrumentation Telemetry

(5)

Tracer self-reporting telemetry: heartbeat intervals, dependency and log collection, and telemetry forwarder configuration.

DD_INSTRUMENTATION_TELEMETRY_ENABLED
Type: boolean
Default: true
Allows Datadog to collect environmental and diagnostic information about your application and runtime to improve the product. Set to false to opt out of instrumentation telemetry.
DD_TELEMETRY_DEBUG
Type: boolean
Default: false
Enables debug mode for instrumentation telemetry. When set, it forces telemetry debug mode on regardless of other configuration.
DD_TELEMETRY_LOG_COLLECTION_ENABLED
Type: boolean
Default: true
Controls whether internal tracer logs are forwarded as part of instrumentation telemetry.
DD_TELEMETRY_METRICS_ENABLED
Type: boolean
Default: true
Controls whether instrumentation telemetry sends internal metrics.
DD_TELEMETRY_METRICS_INTERVAL_SECONDS
Type: decimal
Default: 60
Controls how often the tracer reports metrics to the Datadog agent.

Remote Configuration

(1)

Remote Configuration for receiving live configuration updates from Datadog.

DD_REMOTE_CONFIGURATION_ENABLED
Type: boolean
Default: true
Aliases:DD_REMOTE_CONFIG_ENABLED
Enable or disable remote configuration.

Further Reading