chaostoolkit / chaostoolkit-lib

The Chaos Toolkit core library
https://chaostoolkit.org/
Apache License 2.0
77 stars 46 forks source link

Enhance Experiment Logs to Include Detailed ImportError Information #271

Open rkjakeer opened 6 months ago

rkjakeer commented 6 months ago

Is your feature request related to a problem? Please describe. I am working on a new custom extension and I have encountered occasional errors, such as the one shown below while running experiments with it. This error seems to occur during the custom module import process. Although the module is installed using pip install, we lack detailed information about what caused the import to fail. Running the experiment in verbose mode did not provide additional insights either.

ERROR] [run:188] could not find Python module '<custom-extension>' in activity '<activity-name>'

Describe the solution you'd like To enhance troubleshooting, it would be beneficial if the experiment log also included details about the error. Therefore, I propose logging the ImportError in this section that currently captures the error. Currently, the log output lacks information regarding the root cause of the import errors.

Describe alternatives you've considered I attempted using sys.exc_info() in the specified section, which provided the following error message, aiding in issue resolution:

ImportError (<class 'ImportError'>, ImportError("cannot import name 'setup_logger' from 'logzero' (unknown location)"), <traceback object at 0x7fdaef5584c0>)

Additional context The custom extension was attempting to import setup_logger from logzero and required correction to address the root cause of the issue.