Configure Dapr to send distributed tracing data

Set up Dapr to send distributed tracing data

Note

It is recommended to run Dapr with tracing enabled for any production scenario. You can configure Dapr to send tracing and telemetry data to many observability tools based on your environment, whether it is running in the cloud or on-premises.

Configuration

The tracing section under the Configuration spec contains the following properties:

  1. spec:
  2. tracing:
  3. samplingRate: "1"
  4. otel:
  5. endpointAddress: "https://..."
  6. zipkin:
  7. endpointAddress: "https://..."

The following table lists the properties for tracing:

PropertyTypeDescription
samplingRatestringSet sampling rate for tracing to be enabled or disabled.
stdoutboolTrue write more verbose information to the traces
otel.endpointAddressstringSet the Open Telemetry (OTEL) server address.
otel.isSecureboolIs the connection to the endpoint address encrypted.
otel.protocolstringSet to http or grpc protocol.
zipkin.endpointAddressstringSet the Zipkin server address. If this is used, you do not need to specify the otel section.

To enable tracing, use a configuration file (in self hosted mode) or a Kubernetes configuration object (in Kubernetes mode). For example, the following configuration object changes the sample rate to 1 (every span is sampled), and sends trace using OTEL protocol to the OTEL server at localhost:4317

  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: tracing
  5. spec:
  6. tracing:
  7. samplingRate: "1"
  8. otel:
  9. endpointAddress: "localhost:4317"
  10. isSecure: false
  11. protocol: grpc

Sampling rate

Dapr uses probabilistic sampling. The sample rate defines the probability a tracing span will be sampled and can have a value between 0 and 1 (inclusive). The default sample rate is 0.0001 (i.e. 1 in 10,000 spans is sampled).

Changing samplingRate to 0 disables tracing altogether.

Environment variables

The OpenTelemetry (otel) endpoint can also be configured via an environment variables. The presence of the OTEL_EXPORTER_OTLP_ENDPOINT environment variable turns on tracing for the sidecar.

Environment VariableDescription
OTEL_EXPORTER_OTLP_ENDPOINTSets the Open Telemetry (OTEL) server address, turns on tracing
OTEL_EXPORTER_OTLP_INSECURESets the connection to the endpoint as unencrypted (true/false)
OTEL_EXPORTER_OTLP_PROTOCOLTransport protocol (grpc, http/protobuf, http/json)

Next steps

Learn how to set up tracing with one of the following tools:

Last modified March 21, 2024: Merge pull request #4082 from newbe36524/v1.13 (f4b0938)