Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Check if bootstrap dir is in path before removal #516

Merged
merged 2 commits into from
Jul 19, 2018

Conversation

beezz
Copy link
Contributor

@beezz beezz commented Jul 18, 2018

Module ddtrace.bootstrap.sitecustomize expect that the python application is started using the ddtrace-run command or that the bootstrap_dir is in sys.path see https://github.com/DataDog/dd-trace-py/blob/master/ddtrace/bootstrap/sitecustomize.py#L93

This PR prevent failed tracing initialization by checking presence of bootstrap dir in path.

How to reproduce:

minimal.py

#!/bin/env python
import ddtrace.bootstrap.sitecustomize
» python minimal.py
WARNING:ddtrace.bootstrap.sitecustomize:error configuring Datadog tracing
Traceback (most recent call last):
  File "/home/mkuffa/src/dd-trace-py/ddtrace/bootstrap/sitecustomize.py", line 93, in <module>
    path.remove(bootstrap_dir)
ValueError: list.remove(x): x not in list

While ddtrace-run minimal.py works fine.

@palazzem
Copy link

Thanks for the contribution @beezz (and welcome back as a contributor!). Let me review this PR and see if we can also test easily this behavior. Also I'll check and re-run the CI.

@palazzem palazzem added this to the 0.12.2 milestone Jul 18, 2018
@palazzem palazzem self-requested a review July 18, 2018 15:08
except Exception as e:
loaded = False

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because we catch any kind of exception, we should provide a loaded status since we "silently pass" to avoid crashing the application.

@@ -0,0 +1,7 @@
from __future__ import print_function

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This script returns False without the given patch.

@palazzem palazzem merged commit 7a3d0f6 into DataDog:master Jul 19, 2018
@palazzem
Copy link

Regression test added and merged. Feel free to contribute again if you have any other improvement in mind! Thank you very much @beezz!

@beezz beezz deleted the fix-non-ddtrace-run branch July 19, 2018 13:36
@palazzem palazzem modified the milestones: 0.12.2, 0.13.0 Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants