After you set up the Rust SDK 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.
Configuration keys
48 configuration keys available for this library.
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_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_SERVICE
- Type:
string
Default: unnamed-rust-service
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.
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
- 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_PARTIAL_FLUSH_ENABLED
- 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
- Type:
int
Default: 300
Minimum number of spans in a trace before partial flush is triggered. DD_TRACE_STATS_COMPUTATION_ENABLED
- 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
- Type:
int
Default: 512
Maximum length of the x-datadog-tags header for trace tag propagation. Set to 0 to disable.
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
- 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
- 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.
Distributed trace context propagation, extraction and injection behavior, baggage handling, header tagging, HTTP client and server configuration, and SQL comment injection for Database Monitoring.
- Type:
string
Default: continue
Since: v0.5.0
Specifies how incoming distributed tracing headers should be handled at a service level. Accepted values are: continue: The SDK will continue the distributed trace if the incoming distributed tracing headers represent a valid trace context. restart: The SDK will always start a new trace. If the incoming distributed tracing headers represent a valid trace context, that trace context will be represented as a span link on service entry spans (as opposed to the parent span in the continue configuration). ignore: The SDK will always start a new trace and all incoming distributed tracing headers are ignored. - Type:
boolean
Default: false
When set to true, stops extracting after the first successful trace context extraction. DD_TRACE_PROPAGATION_STYLE
- 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. - 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
- Type:
array
A comma-separated list of header formats to include to propagate distributed traces between services.
Tracer log output settings: log levels, log file paths, log rotation, and startup diagnostics.
DD_LOG_LEVEL
- Type:
string
Default: ERROR
Sets the internal log level for the SDK. Valid values: DEBUG, INFO, WARN, ERROR.
Direct log submission to Datadog, agentless log forwarding, log injection for trace-log correlation, and OpenTelemetry log export.
DD_LOGS_OTEL_ENABLED
- Type:
boolean
Default: true
Since: v0.3.0
Enables support for exporting logs via OTLP.
Runtime metrics collection and DogStatsD connection configuration for metric submission.
DD_DOGSTATSD_HOST
- 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
- 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
- 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.
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_LOG_COLLECTION_ENABLED
- Type:
boolean
Default: true
Controls whether internal tracer logs are forwarded as part of instrumentation telemetry.
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.
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
- Type:
boolean
Default: true
Since: v0.3.0
Enable or disable OpenTelemetry metrics export. OTEL_EXPORTER_OTLP_ENDPOINT
- 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 . - 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
- 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. - 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
- 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
- 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
- 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. - 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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
- 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_PROPAGATORS
- Type:
array
Since: v0.5.0
Configures which propagators are used for extracting and injecting trace context. OTEL_RESOURCE_ATTRIBUTES
- Type:
map
Since: v0.3.0
Set OpenTelemetry resource attributes as a list of (key, value) pairs. OTEL_SERVICE_NAME
- Type:
string
Since: v0.5.0
Sets the application’s default service name. Alias for DD_SERVICE when DD_SERVICE is not set.
Further reading
Additional helpful documentation, links, and articles: