Using OpenTelemetry Collector to collect traces

How to use Dapr to push trace events through the OpenTelemetry Collector.

Note

Dapr directly writes traces using the OpenTelemetry (OTEL) protocol as the recommended method. For observability tools that support OTEL protocol, you do not need to use the OpenTelemetry Collector.

Dapr can also write traces using the Zipkin protocol. Previous to supporting the OTEL protocol, combining the Zipkin protocol with the OpenTelemetry Collector enabled you to send traces to observability tools such as AWS X-Ray, Google Cloud Operations Suite, and Azure AppInsights. This approach remains for reference purposes only.

Using OpenTelemetry Collect to integrate with many backend

Requirements

  1. A installation of Dapr on Kubernetes.

  2. You are already setting up your trace backends to receive traces.

  3. Check OpenTelemetry Collector exporters here and here to see if your trace backend is supported by the OpenTelemetry Collector. On those linked pages, find the exporter you want to use and read its doc to find out the parameters required.

Setting OpenTelemetry Collector

Run OpenTelemetry Collector to push to your trace backend

  1. Check out the file open-telemetry-collector-generic.yaml and replace the section marked with <your-exporter-here> with the correct settings for your trace exporter. Again, refer to the OpenTelemetry Collector links in the Prerequisites section to determine the correct settings.

  2. Apply the configuration with kubectl apply -f open-telemetry-collector-generic.yaml.

Set up Dapr to send trace to OpenTelemetry Collector

Turn on tracing in Dapr

Next, set up both a Dapr configuration file to turn on tracing and deploy a tracing exporter component that uses the OpenTelemetry Collector.

  1. Create a collector-config.yaml file with this content

  2. Apply the configuration with kubectl apply -f collector-config.yaml.

Deploy your app with tracing

When running in Kubernetes mode, apply the appconfig configuration by adding a dapr.io/config annotation to the container that you want to participate in the distributed tracing, as shown in the following example:

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. ...
  5. spec:
  6. ...
  7. template:
  8. metadata:
  9. ...
  10. annotations:
  11. dapr.io/enabled: "true"
  12. dapr.io/app-id: "MyApp"
  13. dapr.io/app-port: "8080"
  14. dapr.io/config: "appconfig"

Some of the quickstarts such as distributed calculator already configure these settings, so if you are using those no additional settings are needed.

That’s it! There’s no need include any SDKs or instrument your application code. Dapr automatically handles the distributed tracing for you.

NOTE: You can register multiple tracing exporters at the same time, and the tracing logs are forwarded to all registered exporters.

Deploy and run some applications. Wait for the trace to propagate to your tracing backend and view them there.

Last modified October 11, 2022: Update to observability docs for OTEL (#2876) (4d860db7)