instana / python-sensor

:snake: Python Distributed Tracing & Metrics Sensor for Instana
https://www.instana.com/
MIT License
69 stars 31 forks source link

Not passing command line arguments to the script #323

Closed cotterpl closed 3 years ago

cotterpl commented 3 years ago

I am trying to setup instana according to: https://www.instana.com/docs/ecosystem/python/ where I:

  1. pip install instana
  2. export AUTOWRAPT_BOOTSTRAP=instana

Everything seems to be working except that I am no longer able to pass command line arguments to python scripts.

Given a script file test.py:

import sys
print(sys.argv)

when I run from the command line:

python test.py a b c

the output is empty list instead of passed arguments.

If I don't set: AUTOWRAPT_BOOTSTRAP=instana instana is not starting and everything is working fine.

python version is 3.8 run as a virtualenv

M4hakala commented 3 years ago

I have found that in load() method (used to activate the Instana sensor via AUTOWRAPT_BOOTSTRAP environment variable) workaround is used (L57), but it is used in a wrong way. hasattr(object, name) function requires an object to be passed as an argument, but a string is passed there. So there is if not hasattr("sys", "argv"): instead if not hasattr(sys, "argv"):.

manojpandey commented 3 years ago

Thanks @cotterpl @M4hakala for bringing this to us 😄