jaegertracing / jaeger

CNCF Jaeger, a Distributed Tracing Platform
https://www.jaegertracing.io/
Apache License 2.0
20.46k stars 2.44k forks source link

Jaeger in a dockerized application #2100

Closed medhedho closed 4 years ago

medhedho commented 4 years ago

Hello,

I'm trying to trace this Spring Boot application: "https://developer.okta.com/blog/2019/02/28/spring-microservices-docker" with the "all-in-one" Jaeger container. I added the "opentracing-spring-jaeger-cloud-starter" to every microservice. When I run these microservices without docker (mvn run), I find my traces in the Jaeger UI. But when I use the attached docker-compose file, I don't find them.

version: '3'
services:
  discovery-server:
    image: developer.okta.com/microservice-docker-discovery:0.0.1-SNAPSHOT
    ports:
      - 8761:8761
    environment :
      - JAEGER_ENDPOINT=http://jaeger:14268/api/traces
    depends_on:
      - jaeger
  CONFIGSERVER:
    image: developer.okta.com/microservice-docker-config:0.0.1-SNAPSHOT
    volumes:
      - ./config-data:/var/config-data
    environment:
      - JAVA_OPTS=
        -DEUREKA_SERVER=http://discovery-server:8761/eureka
        -Dspring.cloud.config.server.native.searchLocations=/var/config-data
      - JAEGER_ENDPOINT=http://jaeger:14268/api/traces
    depends_on:
      - discovery-server
      - jaeger
    ports:
      - 8888:8888
  school-service:
    image: developer.okta.com/microservice-docker-school-service:0.0.1-SNAPSHOT
    environment:
      - JAVA_OPTS=
        -DEUREKA_SERVER=http://discovery-server:8761/eureka
      - JAEGER_ENDPOINT=http://jaeger:14268/api/traces
    depends_on:
      - discovery-server
      - CONFIGSERVER
      - jaeger
  school-ui:
    image: developer.okta.com/microservice-docker-school-ui:0.0.1-SNAPSHOT
    environment:
      - JAVA_OPTS=
        -DEUREKA_SERVER=http://discovery-server:8761/eureka
        -Dspring.profiles.active=production
      - JAEGER_ENDPOINT=http://jaeger:14268/api/traces
    restart: on-failure
    depends_on:
      - discovery-server
      - CONFIGSERVER
      - jaeger
    ports:
      - 8080:8080
  jaeger:
        image: jaegertracing/all-in-one:1.8
        ports:
          - 16686:16686
          - "6831:6831/udp"
          - "6832:6832/udp"
          - "5775:5775/udp"
          - 5778:5778
          - 14268:14268
          - 9411:9411
yurishkuro commented 4 years ago

When you run application in a container, the default 127.0.0.1 address used to reach Jaeger no longer works, because it points to the app container namespace, while Jaeger is running on a different IP. You can use env variables to point to Jaeger container. See example https://github.com/jaegertracing/jaeger/blob/master/examples/hotrod/docker-compose.yml

medhedho commented 4 years ago

The problem was in the services. I had to remove this from each Dockerfile: -Djava.security.egd=file:/dev/./urandom

pavolloffay commented 4 years ago

thanks for reporting back @medhedho