title: Jaeger/Opentracing with Kafka and docker compose
body: <p>I can only find old and incomplete examples of using opentracing/jaeger with Kafka. I want to run an example locally as a proof of concept - opentracing spans to kafka.</p>
  <p>I managed to get some of this working, but on <code>jeager-query</code> service I keep getting:</p>
  <pre class="lang-json prettyprint-override"><code>&quot;msg&quot;:&quot;Failed to init storage factory&quot;,&quot;error&quot;:&quot;kafka: client has run out of available brokers to talk to (Is your cluster reachable?)&quot;
  </code></pre>
  <p>I'm not sure if I need to use some sort of storage i.e. cassandra too?</p>
  <pre class="lang-yaml prettyprint-override"><code>version: '3.8'
  
  services:
    
    zookeeper:
      image: confluentinc/cp-zookeeper
      networks:
        - kafka-net
      container_name: zookeeper
      environment:
          - ZOOKEEPER_CLIENT_PORT=2181
      ports:
          - 2181:2181
  
    kafka:
      image: confluentinc/cp-kafka
      networks:
        - kafka-net
      container_name: kafka
      environment:
          - KAFKA_ZOOKEEPER_CONNECT=zookeeper:2181
          - KAFKA_OFFSETS_TOPIC_REPLICATION_FACTOR=1
          - ALLOW_PLAINTEXT_LISTENER=yes
          - KAFKA_LISTENERS-INTERNAL://kafka:29092,EXTERNAL://localhost:9092
          - KAFKA_ADVERTISED=INTERNAL://kafka:29092,EXTERNAL://localhost:9092
          - KAFKA_ADVERTISED_LISTENERS=INTERNAL://kafka:29092,EXTERNAL://localhost:9092
          - KAFKA_LISTENER_SECURITY_PROTOCOL_MAP=INTERNAL:PLAINTEXT,EXTERNAL:PLAINTEXT
          - KAFKA_INTER_BROKER_LISTENER_NAME=INTERNAL
      ports:
          - 9092:9092
      depends_on:
          - zookeeper
      restart: on-failure
    
    jaeger-collector:
      image: jaegertracing/jaeger-collector
      container_name: jaeger-collector
      networks:
        - kafka-net
      ports:
        - &quot;14250:14250&quot;
        # - &quot;14267:14267&quot;
        - &quot;14268:14268&quot; # HTTP collector port to receive spans
        - &quot;14269:14269&quot; # HTTP health check port
      restart: on-failure
      environment:
        LOG_LEVEL: &quot;debug&quot;
        SPAN_STORAGE_TYPE: &quot;kafka&quot;
        KAFKA_TOPIC: &quot;somekafkatag&quot;
        KAFKA_BROKERS: &quot;kafka:9092&quot;
        KAFKA_PRODUCER_BROKERS: &quot;kafka:29092&quot;
  
    jaeger-agent:
      image: jaegertracing/jaeger-agent
      container_name: jaeger-agent
      networks:
        - kafka-net
      command: [&quot;--reporter.grpc.host-port=jaeger-collector:14250&quot;]
      ports:
        - &quot;5775:5775/udp&quot;
        - &quot;6831:6831/udp&quot;
        - &quot;6832:6832/udp&quot;
        - &quot;5778:5778&quot;
      environment:
        LOG_LEVEL: &quot;debug&quot;
        SPAN_STORAGE_TYPE: &quot;kafka&quot;
      restart: on-failure
      depends_on:
        - jaeger-collector
  
    jaeger-ingester:
      image: jaegertracing/jaeger-ingester
      container_name: jaeger-ingester
      networks:
        - kafka-net
      ports:
        - &quot;14270:14270&quot; # HTTP health check port: http://localhost:14270/
        - &quot;14271:14271&quot; # Metrics port: http://localhost:14271/metrics
      restart: on-failure
      command: [&quot;--kafka.producer.brokers=kafka:9092&quot;]
      environment:
        LOG_LEVEL: &quot;debug&quot;
        INGESTER_PARALLELISM: &quot;1&quot;
        INGESTER_DEADLOCKINTERVAL: &quot;0ms&quot;
        SPAN_STORAGE_TYPE: &quot;kafka&quot;
        KAFKA_CONSUMER_BROKERS: &quot;kafka:9092&quot;
        METRICS_BACKEND: &quot;expvar&quot;
        KAFKA_BROKERS: &quot;kafka:29092&quot;
  
    jaeger-query:
      image: jaegertracing/jaeger-query
      container_name: jaeger-query
      networks:
        - kafka-net
      ports:
        - &quot;16686:16686&quot; # Jaeger UI port
        - &quot;16687:16687&quot; # HTTP health check port: http://localhost:16687/
      restart: on-failure
      environment:
        LOG_LEVEL: &quot;debug&quot;
        SPAN_STORAGE_TYPE: &quot;kafka&quot;
        KAFKA_CONSUMER_BROKERS: &quot;kafka:9092&quot;
        KAFKA_BROKERS: &quot;kafka:29092&quot;
  
  networks:
    kafka-net:
      driver: bridge
  </code></pre>