How-To: Set up Zipkin for distributed tracing

Set up Zipkin for distributed tracing

Configure self hosted mode

For self hosted mode, on running dapr init:

  1. The following YAML file is created by default in $HOME/.dapr/config.yaml (on Linux/Mac) or %USERPROFILE%\.dapr\config.yaml (on Windows) and it is referenced by default on dapr run calls unless otherwise overridden `:
  • config.yaml
  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: daprConfig
  5. namespace: default
  6. spec:
  7. tracing:
  8. samplingRate: "1"
  9. zipkin:
  10. endpointAddress: "http://localhost:9411/api/v2/spans"
  1. The openzipkin/zipkin docker container is launched on running dapr init or it can be launched with the following code.

Launch Zipkin using Docker:

  1. docker run -d -p 9411:9411 openzipkin/zipkin
  1. The applications launched with dapr run by default reference the config file in $HOME/.dapr/config.yaml or %USERPROFILE%\.dapr\config.yaml and can be overridden with the Dapr CLI using the --config param:
  1. dapr run --app-id mynode --app-port 3000 node app.js

Viewing Traces

To view traces, in your browser go to http://localhost:9411 and you will see the Zipkin UI.

Configure Kubernetes

The following steps shows you how to configure Dapr to send distributed tracing data to Zipkin running as a container in your Kubernetes cluster, and how to view them.

Setup

First, deploy Zipkin:

  1. kubectl create deployment zipkin --image openzipkin/zipkin

Create a Kubernetes service for the Zipkin pod:

  1. kubectl expose deployment zipkin --type ClusterIP --port 9411

Next, create the following YAML file locally:

  • tracing.yaml configuration
  1. apiVersion: dapr.io/v1alpha1
  2. kind: Configuration
  3. metadata:
  4. name: tracing
  5. namespace: default
  6. spec:
  7. tracing:
  8. samplingRate: "1"
  9. zipkin:
  10. endpointAddress: "http://zipkin.default.svc.cluster.local:9411/api/v2/spans"

Now, deploy the the Dapr configuration file:

  1. kubectl apply -f tracing.yaml

In order to enable this configuration for your Dapr sidecar, add the following annotation to your pod spec template:

  1. annotations:
  2. dapr.io/config: "tracing"

That’s it! Your sidecar is now configured to send traces to Zipkin.

Viewing Tracing Data

To view traces, connect to the Zipkin service and open the UI:

  1. kubectl port-forward svc/zipkin 9411:9411

In your browser, go to http://localhost:9411 and you will see the Zipkin UI.

zipkin

References

Last modified March 18, 2021: Merge pull request #1321 from dapr/aacrawfi/logos (9a399d5)