---
title: Configuring the C++ SDK
description: Datadog, the leading service for cloud-scale monitoring.
breadcrumbs: >-
  Docs > APM > Application Instrumentation > Configure the Datadog SDK >
  Configuring the C++ SDK
---

# Configuring the C++ SDK

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](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging.md).
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](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging.md) 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.

## Configurations keys{% #configurations-keys %}
**40** configuration keys available for this library.
{% collapsible-section open=null %}
### General Settings{% #registry-general %}
(7)
{% icon name="icon-link-wui" /%}

Top-level Datadog configuration: API keys, service identity, Agent connection, intake site, hostname, global tags, and proxy settings.
`DD_AGENT_HOST` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**Type**: `string` Sets an external environment identifier attached to emitted telemetry for origin and environment attribution.`DD_SERVICE` 
{% icon name="icon-link-wui" /%}
**Type**: `string` Sets the service name for your application.`DD_TAGS` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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.

{% /collapsible-section %}

{% collapsible-section %}
### Tracing Core{% #registry-trace_core %}
(7)
{% icon name="icon-link-wui" /%}

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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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_TAGS_PROPAGATION_MAX_LENGTH` 
{% icon name="icon-link-wui" /%}
**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.
{% /collapsible-section %}

{% collapsible-section %}
### Trace Sampling{% #registry-trace_sampling %}
(5)
{% icon name="icon-link-wui" /%}

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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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.
{% /collapsible-section %}

{% collapsible-section %}
### Trace Propagation{% #registry-trace_propagation %}
(7)
{% icon name="icon-link-wui" /%}

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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**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.
{% /collapsible-section %}

{% collapsible-section %}
### Trace Integrations{% #registry-trace_integrations %}
(1)
{% icon name="icon-link-wui" /%}

Per-integration tracing configuration: enable/disable, analytics, service name, peer service overrides for library integrations and controls for disabling specific instrumentations.

#### Configuration Kinds

Each integration can support one or more of these configuration patterns. Replace `<INTEGRATION>` with the integration name (for example, `GRPC`, `AWS`, `REDIS`).

#### Per-Integration Settings (1 integrations)

Each section lists all configuration keys available for a specific integration.

{% collapsible-section #integration-resource-renaming %}
#### RESOURCE_RENAMING
(1)
{% icon name="icon-link-wui" /%}
`DD_TRACE_RESOURCE_RENAMING_ENABLED` 
{% icon name="icon-link-wui" /%}
**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.
{% /collapsible-section %}

{% /collapsible-section %}

{% collapsible-section %}
### Trace Logging{% #registry-trace_logging %}
(2)
{% icon name="icon-link-wui" /%}

Tracer log output settings: log levels, log file paths, log rotation, and startup diagnostics.
`DD_TRACE_DEBUG` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` Enables emission of startup configuration and diagnostic log lines when the tracer initializes.
{% /collapsible-section %}

{% collapsible-section %}
### Instrumentation Telemetry{% #registry-telemetry %}
(6)
{% icon name="icon-link-wui" /%}

Tracer self-reporting telemetry: heartbeat intervals, dependency and log collection, and telemetry forwarder configuration.
`DD_INSTRUMENTATION_TELEMETRY_ENABLED` 
{% icon name="icon-link-wui" /%}
**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` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `false` Enables debug mode for instrumentation telemetry. When set, it forces telemetry debug mode on regardless of other configuration.`DD_TELEMETRY_HEARTBEAT_INTERVAL` 
{% icon name="icon-link-wui" /%}
**Type**: `decimal` **Default**: `10` Sets the interval for the telemetry status heartbeat (in seconds).`DD_TELEMETRY_LOG_COLLECTION_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` Controls whether internal tracer logs are forwarded as part of instrumentation telemetry.`DD_TELEMETRY_METRICS_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` Controls whether instrumentation telemetry sends internal metrics.`DD_TELEMETRY_METRICS_INTERVAL_SECONDS` 
{% icon name="icon-link-wui" /%}
**Type**: `decimal` **Default**: `60` Controls how often the tracer reports metrics to the Datadog agent.
{% /collapsible-section %}

{% collapsible-section %}
### Remote Configuration{% #registry-remote_config %}
(2)
{% icon name="icon-link-wui" /%}

Remote Configuration for receiving live configuration updates from Datadog.
`DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS` 
{% icon name="icon-link-wui" /%}
**Type**: `decimal` **Default**: `5.0` Sets how often, in seconds, the Datadog Agent is queried for Remote Configuration updates.`DD_REMOTE_CONFIGURATION_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` **Aliases**:`DD_REMOTE_CONFIG_ENABLED` Enable or disable remote configuration.
{% /collapsible-section %}

{% collapsible-section %}
### Instrumentation & Platform{% #registry-instrumentation %}
(3)
{% icon name="icon-link-wui" /%}

Instrumentation setup and platform-specific configuration: auto-injection, third-party library detection, and platform adapters.
`DD_INSTRUMENTATION_INSTALL_ID` 
{% icon name="icon-link-wui" /%}
**Type**: `string` Sets the install ID included in instrumentation telemetry payloads and headers. This can be used to correlate telemetry to a specific installation.`DD_INSTRUMENTATION_INSTALL_TIME` 
{% icon name="icon-link-wui" /%}
**Type**: `string` Sets the install time included in instrumentation telemetry payloads and headers.`DD_INSTRUMENTATION_INSTALL_TYPE` 
{% icon name="icon-link-wui" /%}
**Type**: `string` Sets the install type included in instrumentation telemetry payloads and headers.
{% /collapsible-section %}
(function(){document.querySelectorAll(".registry-copy-link").forEach(function(e){e.addEventListener("click",function(t){t.preventDefault(),t.stopPropagation();const n=window.location.origin+window.location.pathname+e.getAttribute("href");navigator.clipboard.writeText(n).then(function(){e.matches("a")&&(e.classList.add("registry-copy-link--copied"),setTimeout(function(){e.classList.remove("registry-copy-link--copied")},1500))}),history.replaceState(null,"",e.getAttribute("href"))})});function e(){const n=window.location.hash;if(!n)return;const e=document.getElementById(n.substring(1));if(!e)return;let t=e;for(;t;)t.tagName==="DETAILS"&&(t.open=!0),t=t.parentElement;e.tagName==="DETAILS"&&(e.open=!0),setTimeout(function(){e.scrollIntoView({behavior:"smooth",block:"start"})},100)}e(),window.addEventListener("hashchange",e)})()
## Further Reading{% #further-reading %}

- [Source code](https://github.com/DataDog/dd-trace-cpp)
- [Explore your services, resources and traces](https://docs.datadoghq.com/tracing/glossary.md)
- [Propagating trace context](https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation.md)
