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

# Configuring the Rust Tracing Library

After you [set up the Rust SDK](https://docs.datadoghq.com/tracing/trace_collection/custom_instrumentation/rust) with your application, you can optionally configure it using the following environment variables.

## Unified Service Tagging{% #unified-service-tagging %}

It is recommended to use `DD_ENV`, `DD_SERVICE`, and `DD_VERSION` to set `env`, `service`, and `version` for your services.

{% dl %}

{% dt %}
`DD_ENV`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
Set the application's environment, for example: `prod`, `staging`.
{% /dd %}

{% dt %}
`DD_SERVICE`
{% /dt %}

{% dd %}
**Default**: `unnamed-rust-service`
{% /dd %}

{% dd %}
Sets the service name for your application.
{% /dd %}

{% dt %}
`DD_VERSION`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
Set the application's version, for example: `1.2.3` or `6c44da20`.
{% /dd %}

{% dt %}
`DD_TAGS`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
A list of default tags to be added to every span, in `key:value` format, separated by commas. Example: `layer:api,team:intake`.
{% /dd %}

{% /dl %}

## Traces{% #traces %}

{% dl %}

{% dt %}
`DD_TRACE_ENABLED`
{% /dt %}

{% dd %}
**Default**: `true`
{% /dd %}

{% dd %}
Set to `false` to disable tracing.
{% /dd %}

{% dt %}
`DD_TRACE_STATS_COMPUTATION_ENABLED`
{% /dt %}

{% dd %}
**Default**: `true`
{% /dd %}

{% dd %}
Enable computation of trace statistics.
{% /dd %}

{% dt %}
`DD_TRACE_X_DATADOG_TAGS_MAX_LENGTH`
{% /dt %}

{% dd %}
**Default**: `512`
{% /dd %}

{% dd %}
Maximum length of the `x-datadog-tags` header in bytes.
{% /dd %}

{% dt %}
`DD_TRACE_PARTIAL_FLUSH_ENABLED`
{% /dt %}

{% dd %}
**Default**: `false`
{% /dd %}

{% dd %}
Enable partial flushing of traces.
{% /dd %}

{% dt %}
`DD_TRACE_PARTIAL_FLUSH_MIN_SPANS`
{% /dt %}

{% dd %}
**Default**: `300`
{% /dd %}

{% dd %}
Minimum number of spans in a trace before partial flush is triggered.
{% /dd %}

{% dt %}
`DD_REMOTE_CONFIGURATION_ENABLED`
{% /dt %}

{% dd %}
**Default**: `true`
{% /dd %}

{% dd %}
Enable or disable remote configuration. Also accepts the alias `DD_REMOTE_CONFIG_ENABLED`.
{% /dd %}

{% dt %}
`DD_REMOTE_CONFIG_POLL_INTERVAL_SECONDS`
{% /dt %}

{% dd %}
**Default**: `5.0`
{% /dd %}

{% dd %}
Interval in seconds for polling remote configuration updates.
{% /dd %}

{% /dl %}

## Agent{% #agent %}

{% dl %}

{% dt %}
`DD_AGENT_HOST`
{% /dt %}

{% dd %}
**Default**: `localhost`
{% /dd %}

{% dd %}
Sets the hostname of the Datadog Agent.
{% /dd %}

{% dt %}
`DD_TRACE_AGENT_PORT`
{% /dt %}

{% dd %}
**Default**: `8126`
{% /dd %}

{% dd %}
Sets the port of the Datadog Agent for trace collection.
{% /dd %}

{% dt %}
`DD_TRACE_AGENT_URL`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
Sets the URL of the Datadog Agent. Example: `http://localhost:8126`. This takes precedence over `DD_AGENT_HOST` and `DD_TRACE_AGENT_PORT`.
{% /dd %}

{% dt %}
`DD_DOGSTATSD_HOST`
{% /dt %}

{% dd %}
**Default**: `localhost`
{% /dd %}

{% dd %}
Sets the hostname for DogStatsD metric collection.
{% /dd %}

{% dt %}
`DD_DOGSTATSD_PORT`
{% /dt %}

{% dd %}
**Default**: `8125`
{% /dd %}

{% dd %}
Sets the port for DogStatsD metric collection.
{% /dd %}

{% dt %}
`DD_DOGSTATSD_URL`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
Sets the URL for DogStatsD. This takes precedence over `DD_DOGSTATSD_HOST` and `DD_DOGSTATSD_PORT`.
{% /dd %}

{% dt %}
`DD_INSTRUMENTATION_TELEMETRY_ENABLED`
{% /dt %}

{% dd %}
**Default**: `true`
{% /dd %}

{% dd %}
Enable or disable telemetry data collection and sending.
{% /dd %}

{% dt %}
`DD_TELEMETRY_HEARTBEAT_INTERVAL`
{% /dt %}

{% dd %}
**Default**: `60.0`
{% /dd %}

{% dd %}
Interval in seconds for sending telemetry heartbeat messages.
{% /dd %}

{% dt %}
`DD_TELEMETRY_LOG_COLLECTION_ENABLED`
{% /dt %}

{% dd %}
**Default**: `true`
{% /dd %}

{% dd %}
Enable or disable log collection for telemetry.
{% /dd %}

{% /dl %}

## Logging{% #logging %}

{% dl %}

{% dt %}
`DD_LOG_LEVEL`
{% /dt %}

{% dd %}
**Default**: `ERROR`
{% /dd %}

{% dd %}
Sets the internal log level for the tracer. Valid values: `DEBUG`, `INFO`, `WARN`, `ERROR`.
{% /dd %}

{% /dl %}

## Sampling{% #sampling %}

{% dl %}

{% dt %}
`DD_TRACE_SAMPLING_RULES`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
A JSON array of objects to apply for trace sampling. Each rule must have a `sample_rate` between 0.0 and 1.0 (inclusive).
{% /dd %}

{% dt %}
`DD_TRACE_RATE_LIMIT`
{% /dt %}

{% dd %}
**Default**: `100`
{% /dd %}

{% dd %}
Maximum number of traces to sample per second.
{% /dd %}

{% /dl %}

## Trace context propagation{% #trace-context-propagation %}

{% dl %}

{% dt %}
`DD_TRACE_PROPAGATION_STYLE`
{% /dt %}

{% dd %}
**Default**: `datadog,tracecontext`
{% /dd %}

{% dd %}
A comma-separated list of propagation styles to use for both extraction and injection. Supported values are `datadog` and `tracecontext`. See [Propagating Rust Trace Context](https://docs.datadoghq.com/tracing/trace_collection/trace_context_propagation) for more information.
{% /dd %}

{% dt %}
`DD_TRACE_PROPAGATION_STYLE_EXTRACT`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
A comma-separated list of propagation styles to use for extraction. When set, this overrides `DD_TRACE_PROPAGATION_STYLE` for extraction.
{% /dd %}

{% dt %}
`DD_TRACE_PROPAGATION_STYLE_INJECT`
{% /dt %}

{% dd %}
**Default**: `(none)`
{% /dd %}

{% dd %}
A comma-separated list of propagation styles to use for injection. When set, this overrides `DD_TRACE_PROPAGATION_STYLE` for injection.
{% /dd %}

{% dt %}
`DD_TRACE_PROPAGATION_EXTRACT_FIRST`
{% /dt %}

{% dd %}
**Default**: `false`
{% /dd %}

{% dd %}
When set to `true`, stops extracting after the first successful trace context extraction.
{% /dd %}

{% /dl %}

## 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/)
- [Explore your services, resources and traces](https://docs.datadoghq.com/tracing/glossary/)
