I'm instrumenting a dummy FastAPI application using OpenTelemetry and Jaeger as the backend analysis tool.
I managed to make it work using the following two steps:
- Run Jaeger (the Jaeger UI will be accessible on
localhost:16686):
docker run -d --name jaeger \
-e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \
-p 6831:6831/udp \
-p 6832:6832/udp \
-p 5778:5778 \
-p 16686:16686 \
-p 4317:4317 \
-p 4318:4318 \
-p 14250:14250 \
-p 14268:14268 \
-p 14269:14269 \
-p 9411:9411 \
jaegertracing/all-in-one:1.54
- Start my dummy instrumented FastAPI app (reachable on
localhost:8000):
opentelemetry-instrument --service_name dummy_app uvicorn app:app
When I make a request to the root endpoint of my API and check the Jaeger UI, I can successfully see my dummy_app as a service with the corresponding trace resulting of my call.
My problem is when I try to "dockerize" these steps in a docker-compose.yml file.
Here is my Dockerfile for my FastAPI dummy app:
FROM python:3.11.4
WORKDIR /code
COPY ./requirements.txt /code/requirements.txt
RUN pip install --no-cache-dir --upgrade -r /code/requirements.txt
COPY ./app /code/app
CMD ["opentelemetry-instrument", "--service_name", "dummy_app", "uvicorn", "app.main:app", "--host", "0.0.0.0", "--port", "8000"]
And my docker-compose.yml file with the two services defined:
version: '3'
services:
dummy_app:
build:
context: .
dockerfile: Dockerfile
ports:
- 8000:8000
jaeger:
image: jaegertracing/all-in-one:1.54.0
container_name: jaeger
restart: on-failure
ports:
- 6831:6831/udp
- 6832:6832/udp
- 5778:5778
- 16686:16686
- 4317:4317
- 4318:4318
- 14250:14250
- 14268:14268
- 14269:14269
- 9411:9411
environment:
- COLLECTOR_ZIPKIN_HTTP_PORT=9411
I can reach the two services on localhost 8000 and 16686, respectively. But I can't find my dummy_app in the Jaeger UI list of instrumented services. While the two services are running, it seems they are not communicating together.
I am very new to both the OpenTelemetry and Docker technologies. Any help would be greatly appreciated for how to manage to properly run the services with Docker Compose.