odigos icon indicating copy to clipboard operation
odigos copied to clipboard

PYPATH is overridden during instrumentation

Open esara opened this issue 11 months ago • 2 comments

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

esara avatar Mar 22 '24 18:03 esara

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.

RonFed avatar Mar 23 '24 20:03 RonFed

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

esara avatar Mar 23 '24 21:03 esara