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

# Configuring the Rust SDK

After you [set up the Rust SDK](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/rust.md) with your application, you can optionally configure it using the following environment variables.
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_ENV`, `DD_SERVICE`, and `DD_VERSION` to set `env`, `service`, and `version` for your services.

## Configurations keys{% #configurations-keys %}
**47** configuration keys available for this library.
{% collapsible-section open=null %}
### General Settings{% #registry-general %}
(5)
{% 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_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_SERVICE` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `unnamed-rust-service` 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_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_PARTIAL_FLUSH_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `false` Enables incrementally flushing large traces to the Datadog Agent, reducing the chance of rejection by the Agent. Use only when you have long-lived traces or traces with many spans.`DD_TRACE_PARTIAL_FLUSH_MIN_SPANS` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `300` Minimum number of spans in a trace before partial flush is triggered.`DD_TRACE_STATS_COMPUTATION_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` **Aliases**:`DD_TRACE_TRACER_METRICS_ENABLED` Controls whether client-side trace statistics computation is enabled. When enabled, the tracer pre-aggregates span stats for ingestion.`DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `512` Maximum length of the `x-datadog-tags` header for trace tag propagation. Set to 0 to disable.
{% /collapsible-section %}

{% collapsible-section %}
### Trace Sampling{% #registry-trace_sampling %}
(2)
{% 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_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_SAMPLING_RULES` 
{% icon name="icon-link-wui" /%}
**Type**: `array` 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 %}
(4)
{% 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_TRACE_PROPAGATION_EXTRACT_FIRST` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `false` When set to true, stops extracting after the first successful trace context extraction.`DD_TRACE_PROPAGATION_STYLE` 
{% icon name="icon-link-wui" /%}
**Type**: `array` **Default**: `datadog,tracecontext` 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` 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` A comma-separated list of header formats to include to propagate distributed traces between services.
{% /collapsible-section %}

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

Tracer log output settings: log levels, log file paths, log rotation, and startup diagnostics.
`DD_LOG_LEVEL` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `ERROR` Sets the internal log level for the SDK. Valid values: `DEBUG`, `INFO`, `WARN`, `ERROR`.
{% /collapsible-section %}

{% collapsible-section %}
### Log Submission & Correlation{% #registry-logs %}
(1)
{% icon name="icon-link-wui" /%}

Direct log submission to Datadog, agentless log forwarding, log injection for trace-log correlation, and OpenTelemetry log export.
`DD_LOGS_OTEL_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` **Since**: `v0.3.0` Enables support for exporting logs via OTLP.
{% /collapsible-section %}

{% collapsible-section %}
### Runtime Metrics{% #registry-runtime_metrics %}
(3)
{% icon name="icon-link-wui" /%}

Runtime metrics collection and DogStatsD connection configuration for metric submission.
`DD_DOGSTATSD_HOST` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `localhost` **Aliases**:`DD_DOGSTATSD_HOSTNAME` Override the address of the trace Agent host that the default tracer attempts to submit DogStatsD metrics to. Use `DD_AGENT_HOST` to override `DD_DOGSTATSD_HOST`.`DD_DOGSTATSD_PORT` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `8125` The port of the DogStatsD Agent that metrics are submitted to. If the Agent configuration sets `dogstatsd_port` or `DD_DOGSTATSD_PORT` to something other than the default `8125`, then this tracing library `DD_DOGSTATSD_PORT` must match it.`DD_DOGSTATSD_URL` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `http://localhost:8125` The URL used to connect to the DogStatsD endpoint. Takes precedence over `DD_AGENT_HOST` and `DD_DOGSTATSD_PORT`. Supports `udp://` or `unix://` schemes only.
{% /collapsible-section %}

{% collapsible-section %}
### Instrumentation Telemetry{% #registry-telemetry %}
(3)
{% 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_HEARTBEAT_INTERVAL` 
{% icon name="icon-link-wui" /%}
**Type**: `decimal` **Default**: `60.0` Interval, in seconds, between telemetry heartbeat messages emitted by the tracer.`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.
{% /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 %}
### OpenTelemetry Compatibility{% #registry-otel %}
(19)
{% icon name="icon-link-wui" /%}

Standard OpenTelemetry environment variables supported by Datadog SDKs: resource attributes, propagators, trace sampler, OTLP exporter configuration, and batch span processor settings.
`DD_METRICS_OTEL_ENABLED` 
{% icon name="icon-link-wui" /%}
**Type**: `boolean` **Default**: `true` **Since**: `v0.3.0` Enable or disable OpenTelemetry metrics export.`OTEL_EXPORTER_OTLP_ENDPOINT` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Since**: `v0.3.0` Specifies the base URL for sending OTLP data for all signals unless overridden. **Default (gRPC)**: `http://localhost:4317` . **Default (HTTP)**: `http://localhost:4318` .`OTEL_EXPORTER_OTLP_HEADERS` 
{% icon name="icon-link-wui" /%}
**Type**: `map` **Since**: `v0.3.0` Configuration key to set custom headers for OTLP export (fallback for metrics-specific headers). Used when metrics-specific OTLP headers are not set. Format: api-key=key,other=value.`OTEL_EXPORTER_OTLP_LOGS_ENDPOINT` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Since**: `v0.3.0` **Aliases**:`OTEL_EXPORTER_OTLP_ENDPOINT` URL for sending OTLP logs. Takes precedence over `OTEL_EXPORTER_OTLP_ENDPOINT`. Defaults to `http://localhost:4317` for gRPC and `http://localhost:4318/v1/logs` for HTTP.`OTEL_EXPORTER_OTLP_LOGS_HEADERS` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Since**: `v0.3.0` **Aliases**:`OTEL_EXPORTER_OTLP_HEADERS` Specifies a comma-separated list of key-value pairs to be used as headers on outgoing OTLP logs requests. Takes precedence over the general `OTEL_EXPORTER_OTLP_HEADERS`.`OTEL_EXPORTER_OTLP_LOGS_PROTOCOL` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `SDK-dependent, but will typically be either http/protobuf or grpc.` **Since**: `v0.3.0` Specifies the OTLP transport protocol for logs. Takes precedence over `OTEL_EXPORTER_OTLP_PROTOCOL`. : **Accepted values**: `grpc`, `http/protobuf`, `http/json``OTEL_EXPORTER_OTLP_LOGS_TIMEOUT` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `10000` **Since**: `v0.3.0` **Aliases**:`OTEL_EXPORTER_OTLP_TIMEOUT` Specifies the timeout (in milliseconds) for a single outgoing OTLP logs request. Takes precedence over the general `OTEL_EXPORTER_OTLP_TIMEOUT`.`OTEL_EXPORTER_OTLP_METRICS_ENDPOINT` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Since**: `v0.3.0` **Aliases**:`OTEL_EXPORTER_OTLP_ENDPOINT` If non-empty, used as the OTLP metrics endpoint. Otherwise falls back to `OTEL_EXPORTER_OTLP_ENDPOINT`, then to `http://<DD_TRACE_AGENT_URL host>:4317/4318` based on protocol. For `http/protobuf`, `/v1/metrics` is appended if missing.`OTEL_EXPORTER_OTLP_METRICS_HEADERS` 
{% icon name="icon-link-wui" /%}
**Type**: `map` **Since**: `v0.3.0` Specifies a comma-separated list of key-value pairs to be used as headers on outgoing OTLP metrics requests (for example, `api-key=key,other-config=value`). Takes precedence over the general `OTEL_EXPORTER_OTLP_HEADERS`.`OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Since**: `v0.3.0` Specifies the OTLP transport protocol to use for metrics data. Takes precedence over the general `OTEL_EXPORTER_OTLP_PROTOCOL`. **Accepted values**: `grpc`, `http/protobuf`, `http/json`.`OTEL_EXPORTER_OTLP_METRICS_TEMPORALITY_PREFERENCE` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `delta` **Since**: `v0.3.0` Controls metrics aggregation temporality. Accepted values: `delta` or `cumulative` (case-insensitive); empty/invalid values are treated as `delta`.`OTEL_EXPORTER_OTLP_METRICS_TIMEOUT` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Since**: `v0.3.0` Used as the exporter network timeout (ms) for OTLP metrics requests. If set to `0`, the library falls back to `OTEL_EXPORTER_OTLP_TIMEOUT`.`OTEL_EXPORTER_OTLP_PROTOCOL` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `grpc` **Since**: `v0.3.0` Used as the fallback OTLP protocol for metrics when `OTEL_EXPORTER_OTLP_METRICS_PROTOCOL` is unset. Parsed values: `grpc`, `http/protobuf`, `http/json` (case-insensitive). Note: `http/json` is currently unsupported for metrics and disables metrics export; `grpc`/`http/protobuf` require the corresponding Cargo features (`metrics-grpc`/`metrics-http`).`OTEL_EXPORTER_OTLP_TIMEOUT` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `10000` **Since**: `v0.3.0` Default timeout, in milliseconds, for OTLP export requests. Used as a fallback when a signal-specific timeout is not set.`OTEL_LOGS_EXPORTER` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `otlp` **Since**: `v0.3.0` Datadog SDKs that support OTLP log export should default to otlp; all others should default to None/null.`OTEL_METRIC_EXPORT_INTERVAL` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `10000` **Since**: `v0.3.0` Interval, in milliseconds, between metric export attempts. The default of 10000 (10s) is Datadog's recommended value and differs from the OpenTelemetry specification default of 60000 ms.`OTEL_METRIC_EXPORT_TIMEOUT` 
{% icon name="icon-link-wui" /%}
**Type**: `int` **Default**: `7500` **Since**: `v0.3.0` Maximum time, in milliseconds, allowed to collect and export a single batch of metrics. The default of 7500 (7.5s) is Datadog's recommended value and differs from the OpenTelemetry specification default of 30000 ms.`OTEL_METRICS_EXPORTER` 
{% icon name="icon-link-wui" /%}
**Type**: `string` **Default**: `otlp` **Since**: `v0.3.0` Specifies the OpenTelemetry metrics exporter. The only accepted values are `otlp` and `none`. Setting it to `none` disables both OTel metric emission and APM runtime metrics (equivalent to `DD_RUNTIME_METRICS_ENABLED=false`).`OTEL_RESOURCE_ATTRIBUTES` 
{% icon name="icon-link-wui" /%}
**Type**: `map` **Since**: `v0.3.0` Set OpenTelemetry resource attributes as a list of `(key, value)` pairs.
{% /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-rs)
- [Propagating trace context](https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation.md)
- [Explore your services, resources and traces](https://docs.datadoghq.com/tracing/glossary.md)
