Skip to content

opentelemetry-instrument command can cause recursive creation of subprocesses #1050

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Closed
aabmass opened this issue Apr 12, 2022 · 0 comments · Fixed by #1066
Closed

opentelemetry-instrument command can cause recursive creation of subprocesses #1050

aabmass opened this issue Apr 12, 2022 · 0 comments · Fixed by #1066
Assignees
Labels
bug Something isn't working

Comments

@aabmass
Copy link
Member

aabmass commented Apr 12, 2022

Describe your environment

Python3.9, linux.

Steps to reproduce
Using opentelemetry-instrument with any exporter or instrumentation which invokes a python subprocess during initialization. For example, the opentelemetry-exporter-gcp-trace exporter may invoke the gcloud (written in python) command in a subprocess to get project information and authentication tokens. The subprocess will then try to autoinstrument, creating a recursive loop of subprocesses being created.

What is the expected behavior?
Auto-instrumentation should not apply to subprocesses created in the initialize() phase of auto-instrumentation. The PYTHONPATH environment variable should have the sitecustomize.py dirname stripped out at the beginning of sitecustomize.py. This would prevent subprocesses from being autoinstrumented during setup, which can cause a loop.

What is the actual behavior?
PYTHONPATH is correctly stripped later on to avoid this

finally:
environ["PYTHONPATH"] = sub(
rf"{dirname(abspath(__file__))}{pathsep}?",
"",
environ["PYTHONPATH"],
)

However, any subprocesses created in these lines will cause a loop.

Additional context
I can write a repro if necessary.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
bug Something isn't working
Projects
None yet
1 participant