Zipkin tracing not working for docker-compose and Dapr
Asked Answered
D

2

6

Traces that should have been sent by dapr runtime to zipkin server somehow fails to reach it.

The situation is the following:

I'm using Docker Desktop on my Windows PC. I have downloaded the sample from dapr repository (https://github.com/dapr/samples/tree/master/hello-docker-compose) which runs perfectly out of the box with docker-compose up.

Then I've added Zipkin support as per dapr documentation:

  1. added this service in the bottom of docker-compose.yml
  zipkin:
    image: "openzipkin/zipkin"
    ports:
      - "9411:9411"
    networks:
      - hello-dapr 
  1. added config.yaml in components folder
apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: daprsystem
spec:
  mtls:
    enabled: false
  tracing:
    enabled: true
    exporterType: zipkin
    samplingRate: "1"
    expandParams: true
    includeBody: true
    zipkin:
      endpointAddress: "http://zipkin:9411/api/v2/spans"    

When application runs, it should send traces to the server, but nothing is found in zipkin UI and logs.

Strange thing start to appear in the logs from nodeapp-dapr_1 service: error while reading spiffe id from client cert

pythonapp-dapr_1  | time="2021-03-15T19:14:17.9654602Z" level=debug msg="found mDNS IPv4 address in cache: 172.19.0.7:34549" app_id=pythonapp instance=ce32220407e2 scope=dapr.contrib type=log ver=edge
nodeapp-dapr_1    | time="2021-03-15T19:14:17.9661792Z" level=debug msg="error while reading spiffe id from client cert: unable to retrieve peer auth info. applying default global policy action" app_id=nodeapp instance=773c486b5aac scope=dapr.runtime.grpc.api type=log ver=edge
nodeapp_1         | Got a new order! Order ID: 947
nodeapp_1         | Successfully persisted state.

Additional info - current dapr version used is 1.0.1. I made sure that security (mtls) is disabled in config file.

Downrange answered 15/3, 2021 at 21:59 Comment(0)
L
4

Configuration file is supposed to be in different folder then components.

  1. Create new folder e.g. dapr next to the components folder.
  2. Move components folder into newly created dapr folder.
  3. Then create config.yaml in dapr folder.
  4. Update docker-compose accordingly.

docker-compose

services:
  nodeapp-dapr:
    image: "daprio/daprd:edge"
    command: ["./daprd",
     "-app-id", "nodeapp",
     "-app-port", "3000",
     "-placement-host-address", "placement:50006",
     "-dapr-grpc-port", "50002",
     "-components-path", "/dapr/components",
     "-config", "/dapr/config.yaml"]
    volumes:
      - "./dapr/components/:/dapr"
    depends_on:
      - nodeapp
    network_mode: "service:nodeapp"

config.yaml

apiVersion: dapr.io/v1alpha1
kind: Configuration
metadata:
  name: daprConfig
spec:
  mtls:
    enabled: false
  tracing:
    enabled: true
    samplingRate: "1"
    expandParams: true
    includeBody: true
    zipkin:
      endpointAddress: http://host.docker.internal:9411/api/v2/spans

I had issue with localhost and 127.0.0.1 in URL which I resolved using host.docker.internal as hostname.

PS: Don't forget to kill all *-dapr_1 containers so it can load new configuration.

Landslide answered 16/6, 2021 at 16:39 Comment(1)
Thanks! But had to modify mounting of volume into this -> volumes: - "./dapr/:/dapr"Sibylle
O
0

create a components directory and put your all components file (.yaml) /component/*.yaml create a config folder and create config.yaml file and put below code inside it /config/config.yaml

apiVersion: dapr.io/v1alpha1
    kind: Configuration
    metadata:
      name: daprConfig
    spec:
      mtls:
        enabled: false
      tracing:
        enabled: true
        exporterType: zipkin
        samplingRate: "1"
        expandParams: true
        includeBody: true
        zipkin:
          endpointAddress: "http://zipkin:9411/api/v2/spans" 

this is the docker compose you can run on your system make sure you replace the docker Dockerfile path (./hello-world) create docker-compose.yml file and put following code inside that file.

version: '3'
services:
  hello-world:
    build:
      context: ./hello-world 
    ports:
      - "7001:7001"
      - "7901:7901"
      - "3500:3500"
    environment:
      - DAPR_LOG_LEVEL=info
    depends_on:
      - redis
      - zipkin
      - placement
      - dapr-dashboard
    networks:
      - hello-world-dapr
  hello-world-sidecar:
    image: "daprio/daprd:edge"
    command: [
      "./daprd",
     "--app-id", "hello-world",
     "--app-port", "7001",
     "-dapr-http-port" , "3500",
     "-enable-profiling" ,
     "-profile-port", "7777",
     "--placement-host-address", "placement:50006", 
     "-components-path", "/components",
     "-config", "/configuration/config.yml"
     ]
    environment:
      - DAPR_LOG_LEVEL=info
      - DAPR_CONFIG=/configuration/config.yml
    volumes:
        - "./components/:/components"
        - "./config/:/configuration" 
    depends_on:
      - hello-world
    labels:
      - "dapr.io/enabled=true"  # Enable Dapr for this service
      - "dapr.io/config=configstore"
    network_mode: "service:hello-world" 

  dapr-dashboard:
    image: "daprio/dashboard:latest"
    ports:
      - "8080:8080"
    command: [ 
      "--docker-compose=true", 
      "--components-path=/components", 
      "--config-path=/config", 
      "--docker-compose-path=/docker-compose.yml" ]
    volumes:
      - ./components/:/components
      - ./config/:/config
      - ./docker-compose.yml:/docker-compose.yml
    networks:
      - hello-world-dapr
  placement:
    image: "daprio/dapr"
    command: ["./placement", "--port", "50006"]
    ports:
      - "50006:50006"
  redis:
    image: "redis:latest"
    ports:
      - "6379:6379"  # Map the container's Redis port to the host's port
    networks:
      - hello-world-dapr
    environment:
      - ENABLE_OVERCOMMIT_MEMORY=true
  zipkin:
    image: "openzipkin/zipkin"
    ports:
      - "9411:9411"
    networks:
      - hello-world-dapr
networks:
  hello-world-dapr:
    driver: bridge

you can see dapr dashboard on (your_ip:8080) you can see zipkin on (your_ip:9411)

Oliana answered 29/8 at 7:58 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.