odigos
odigos copied to clipboard
PYPATH is overridden during instrumentation
Describe the bug We are using odigos to autoinstrument a python application, but the app is written/containerized with a predefined PYPATH and the autoinstrumention overrides it and breaks the application startup.
To Reproduce Create a containerized python app with a PYPATH set in the container build.
PYTHONPATH=/pylib:/src
but odigos changes it to
PYTHONPATH=/var/odigos/python/opentelemetry/instrumentation/auto_instrumentation:/var/odigos/python
at which point the app does not find its own python libraries and fails
Expected behavior It would great to append the PYPATH instead of overwriting it, similar to https://github.com/keyval-dev/odigos/pull/1031 for node
Hi @esara, thanks for opening this issue.
We are aware of this problem, and we could add PYTHONPATH
to the env vars we append (similar to what was added to node in #1031), however, that approach is only valid for env vars that are declared as part of the k8s deployment. Unfortunately, we can't use that approach for env vars which are part of the container build, for that we will need a more involved solution.
Thanks @RonFed , I understand, env vars that are spelled out in the deployment/template spec can be reliably parsed
It is probably not as reliable, but it may be possible to parse out the runtime PYPATH of the running process (to be instrumented) as an option? something like this:
$ xargs --null --max-args=1 echo < /proc/1/environ|grep PYTHON
PYTHONPATH=/pylib:/src