0
votes

I'm running a Spring-Boot application inside a docker container and want to instrument it with OpenTracing using the Jaeger client from Uber.

For the instrumentation I'm using the OpenTracing Spring Web library in combination with the Jaeger client.

The following code snippet configures the tracer in the application:

@Bean
public io.opentracing.Tracer jaegerTracer() {
    return new Configuration("hello_service", new Configuration.SamplerConfiguration(ProbabilisticSampler.TYPE, 1),
            new Configuration.ReporterConfiguration())
            .getTracer();
}

I can see the traces when I run the application (not inside a Docker container) and start Jaeger with the following command:

docker run -d -e
COLLECTOR_ZIPKIN_HTTP_PORT=9411
-p 5775:5775/udp
-p 6831:6831/udp
-p 6832:6832/udp
-p 5778:5778
-p 16686:16686
-p 14268:14268
-p 9411:9411
jaegertracing/all-in-one:latest

But when I wrap the Spring-Boot application inside a Docker container with the following docker-compose file and start the Jaeger client again I can't see any traces.

version: '2'

services:
        demo:
                build: opentracing_demo/.
                ports: 
                        - "8080:8080"

After that I tried to declare the Jaeger docker container in the same docker-compose file and added a link from the demo service to the jaeger service:

version: '2'

services:
    demo:
            build: opentracing_demo/.
            ports: 
                    - "8080:8080"
            links:
                    - jaeger
    jaeger: 
            image: jaegertracing/all-in-one:latest
            ports:
                    - "5775:5775/udp"
                    - "6831:6831/udp"
                    - "6832:6832/udp"
                    - "5778:5778"
                    - "16686:16686"
                    - "14268:14268"
                    - "9411:9411"

But I still can't see any traces in the Jaeger client.

For hours I have tried different approaches but didn't make any progress so far, if somebody could help me out I would greatly appreciate it!

You can find my demo project on GitHub.

1

1 Answers

1
votes

But when I wrap the Spring-Boot application inside a Docker container with the following docker-compose file and start the Jaeger client again I can't see any traces

That's because the Jaeger client will, by default, send the spans via UDP to an agent at localhost. When your application is running in a Docker container, your localhost there is the container itself, so that the spans are lost.

As you are linking the Jaeger container with your application, you may want to get it solved by exporting the env var JAEGER_AGENT_HOST to jaeger.