-
Notifications
You must be signed in to change notification settings - Fork 417
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
chore(integrations): remove required_modules from integrations #11719
base: main
Are you sure you want to change the base?
Conversation
|
2634736
to
2a29668
Compare
BenchmarksBenchmark execution time: 2024-12-27 20:30:33 Comparing candidate commit a523807 in PR branch Found 5 performance improvements and 0 performance regressions! Performance is the same for 389 metrics, 2 unstable metrics. scenario:iast_aspects-ospathdirname_aspect
scenario:iast_aspects-ospathsplit_aspect
scenario:iast_aspects-ospathsplitdrive_aspect
scenario:iast_aspects-ospathsplitext_aspect
scenario:iast_aspects-replace_aspect
|
2a29668
to
7e13140
Compare
Datadog ReportBranch report: ✅ 0 Failed, 55 Passed, 1413 Skipped, 1m 17.72s Total duration (32m 37.73s time saved) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🙌
from ddtrace.contrib.internal.coverage.patch import get_version | ||
from ddtrace.contrib.internal.coverage.patch import patch | ||
from ddtrace.contrib.internal.coverage.patch import unpatch | ||
log = get_logger(__name__) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NB: Just curious, do you know why we have this here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably some copy-pasta. It seems to have been there since the beginning of this file's history, and was already unused back then. 😛 We can probably remove it.
from ddtrace.contrib.internal.django.patch import unpatch | ||
|
||
__all__ = ["patch", "unpatch", "_patch", "get_version"] | ||
__all__ = ["patch", "unpatch", "_patch", "get_version"] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we prepare to exclude _patch
while we're doing this clean up, and deprecate it for 3.x?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Honestly I think we could make patch, unpatch and get_version functions internal for all integrations. There's no good reason to make these operations public.
If we really need to expose an api for unpatching an integration (which I don't think we should) we could introduce one unpatch/unpatch_all method in _monkey.py. This is something we could discuss in the next guild meeting.
Since ddtrace v1.9.0 modules are only patched after import. There is no need to check whether a module exists in
ddtrace.contrib.integration_name.__init__
. If a library is not installed, it won't be patched.require_modules
should only be used when a ddtrace integration requires additional libraries (for example the web3 integration can only be enabled if web3_driver is also installed). Right now there is no integrations that have such a dependency.With this change objects exposed in
ddtrace.contrib.<integration_name>.__all__
will always be available. Accessing these objects will not raise an AttributeError and crash an application: ex.Checklist
Reviewer Checklist