blueswen / fastapi-jaeger

Trace FastAPI with Jaeger through OpenTelemetry Python API and SDK.
85 stars 22 forks source link

[question] container names for compose from `app_b` -> `fastapi-jaeger_app-b_1` #2

Closed larrycai closed 1 year ago

larrycai commented 1 year ago

Don't know what's the wrong with my env? I use podman-compose @ Mac, but it shall be the same.

forget how to fix it, I got the container name is fastapi-jaeger_app-a_1 with extra prefix fastapi-jaeger and suffix _1.

I have to change in all related areas to make it work as expected

But I think it shall not work like this, what's wrong with my env? I use podman-compose @ Mac, but it shall be the same

Can you paste your console out in the readme, I got it like below.

$ podman ps
CONTAINER ID  IMAGE                                                   COMMAND               CREATED         STATUS                 PORTS                                                                       NAMES
645c7459b3f8  localhost/fastapi-jaeger_app-a:latest                   uvicorn main:app ...  25 seconds ago  Up 14 seconds          0.0.0.0:8000->8000/tcp                                                      fastapi-jaeger_app-a_1
ffd1e27990ee  localhost/fastapi-jaeger_app-b:latest                   uvicorn main:app ...  24 seconds ago  Up 13 seconds          0.0.0.0:8001->8000/tcp                                                      fastapi-jaeger_app-b_1
3334db65abff  localhost/fastapi-jaeger_app-c:latest                   uvicorn main:app ...  23 seconds ago  Up 12 seconds          0.0.0.0:8002->8000/tcp                                                      fastapi-jaeger_app-c_1
08caf128b172  localhost/fastapi-jaeger_app-d:latest                   uvicorn main:app ...  21 seconds ago  Up 11 seconds          0.0.0.0:8003->8000/tcp                                                      fastapi-jaeger_app-d_1
b9c68f04cbfd  docker.io/library/cassandra:4.1.2                       cassandra -f          20 seconds ago  Up 10 seconds                                                                                      fastapi-jaeger_cassandra_1
eea4cb843e23  docker.io/jaegertracing/jaeger-cassandra-schema:1.47.0                        19 seconds ago  Up 9 seconds                                                                                       fastapi-jaeger_cassandra-schema_1
c8592793aee5  docker.io/jaegertracing/jaeger-collector:1.47.0         --cassandra.keysp...  17 seconds ago  Up Less than a second  0.0.0.0:39969->4317/tcp, 0.0.0.0:41079->4318/tcp, 0.0.0.0:39891->14250/tcp  fastapi-jaeger_jaeger-collector_1
20075f5cf1a8  docker.io/otel/opentelemetry-collector-contrib:0.81.0   --config=/conf/co...  15 seconds ago  Up 6 seconds           0.0.0.0:39077->4317/tcp, 0.0.0.0:44199->4318/tcp                            fastapi-jaeger_otel-collector_1
blueswen commented 1 year ago

Hi @larrycai ,

Sorry for the late reply. The container name looks correct to me, and I had put my container status in readme. There are some differences like underline or dash, but I think that just because podman compose and docker compose have different patterns to generate the container name dynamically.

Back to your main question about why the containers can't communicate with each other even though you already modified the host inmain.py when using podman compose. In docker compose, each container can communicate with each other with service name(the key in compose file's services section) because they are in the same network. So there is no need to modify the host name, just keep it with the service name.

Since I am not using podman, I can't reproduce your issue. But I think it may be related to the network type you are using for podman, there are some discussion on https://github.com/containers/podman-compose/issues/541#issuecomment-1221417067 and https://github.com/containers/podman-compose/issues/455#issue-1175346762. You can try to switch your podman network from cri to netavark, then your container may communicate with each other with service name.

There is a post Podman 4.0's new network stack: What you need to know from RedHat may help you too.

larrycai commented 1 year ago

Yes, u r correct. I checked the /etc/hosts, it actually goes via DNS.

thank