aws / aws-xray-sdk-java

The official AWS X-Ray Recorder SDK for Java.
Apache License 2.0
96 stars 99 forks source link

ECSPlugin: could not obtain the container id from /proc/self/cgroup #415

Open lucaas-webpi opened 6 days ago

lucaas-webpi commented 6 days ago

I embedded xray sdk into my java program running in ECS service to send xray traces to CloudWatch. The ECSPlugin is using com.amazonaws.xray.utils.DockerUtils to get the container id from file /proc/self/cgroup. The DockerUtils could not get the container id from /proc/self/cgroup because the program is running within the docker container. We do have ECS metadata endpoint V4 activated and the container id should be obtained from the metadata.

mxiamxia commented 1 day ago

Applications running inside Container should be able to access cgroup file. Do you see any errors from your application logs?

lucaas-webpi commented 1 day ago

Applications running inside Container should be able to access cgroup file. Do you see any errors from your application logs?

The cgroup file in the docker container doesn't contain a container ID.

bash-4.2# cat /proc/self/cgroup 0::/

Here are logs from application:

com.amazonaws.xray.AWSXRayRecorderBuilder lambda$build$1 INFO: Collecting trace metadata from com.amazonaws.xray.plugins.ECSPlugin. com.amazonaws.xray.utils.DockerUtils getContainerId WARNING: Failed to read container ID because file:/proc/self/cgroup didn't contain an ID.