-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore(integrations): internalize get_version, patch, and unpatch for …
…all integrations [3.0] (#11916) Requires: [chore: avoids using deprecated modules in tests and log injection [3.0 prep]](#11835). Follow up to: #11918 This change internalizes the following functions: - `ddtrace.contrib.<integration_name>.patch()` - `ddtrace.contrib.<integration_name>.unpatch()` - `ddtrace.contrib.<integration_name>.get_version()` This change also internalizes all integrations that only expose `patch()`, `unpatch()`, and `get_version()` functions. ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
- Loading branch information
Showing
171 changed files
with
1,538 additions
and
1,521 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,73 @@ | ||
from ddtrace._trace import trace_handlers # noqa:F401 | ||
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning | ||
from ddtrace.internal.utils.importlib import func_name # noqa:F401 | ||
from ddtrace.internal.utils.importlib import module_name # noqa:F401 | ||
from ddtrace.internal.utils.importlib import require_modules # noqa:F401 | ||
from ddtrace.vendor.debtcollector import deprecate | ||
|
||
|
||
def __getattr__(name): | ||
if name in ( | ||
"aiohttp", | ||
"asgi", | ||
"bottle", | ||
"celery", | ||
"cherrypy", | ||
"falcon", | ||
"flask_cache", | ||
"pylibmc", | ||
"pyramid", | ||
"requests", | ||
"sqlalchemy", | ||
"wsgi", | ||
"trace_utils", | ||
"internal", | ||
): | ||
# following packages/modules are not deprecated and will not be removed in 3.0 | ||
pass | ||
elif name in ("trace_handlers", "func_name", "module_name", "require_modules"): | ||
# the following attributes are exposed in ddtrace.contrib.__init__ and should be | ||
# removed in v3.0 | ||
deprecate( | ||
("ddtrace.contrib.%s is deprecated" % name), | ||
category=DDTraceDeprecationWarning, | ||
removal_version="3.0.0", | ||
) | ||
elif name in ("aiobotocore", "httplib", "kombu", "snowflake", "sqlalchemy", "tornado", "urllib3"): | ||
# following integrations are not enabled by default and require a unique deprecation message | ||
deprecate( | ||
f"ddtrace.contrib.{name} is deprecated", | ||
message="Avoid using this package directly. " | ||
f"Set DD_TRACE_{name.upper()}_ENABLED=true and use ``ddtrace.auto`` or the " | ||
"``ddtrace-run`` command to enable and configure this integration.", | ||
category=DDTraceDeprecationWarning, | ||
removal_version="3.0.0", | ||
) | ||
elif name in ("redis_utils", "trace_utils_redis", "trace_utils_async"): | ||
deprecate( | ||
f"The ddtrace.contrib.{name} module is deprecated", | ||
message="Import from ``ddtrace.contrib.trace_utils`` instead.", | ||
category=DDTraceDeprecationWarning, | ||
removal_version="3.0.0", | ||
) | ||
elif name == "flask_login": | ||
deprecate( | ||
"""The flask_login integration is deprecated and will be deleted. | ||
We recommend customers to switch to manual instrumentation. | ||
https://docs.datadoghq.com/security/application_security/threats/add-user-info/?tab=loginsuccess&code-lang=python#adding-business-logic-information-login-success-login-failure-any-business-logic-to-traces | ||
""", | ||
message="", | ||
category=DDTraceDeprecationWarning, | ||
) | ||
else: | ||
deprecate( | ||
f"ddtrace.contrib.{name} is deprecated", | ||
message="Avoid using this package directly. " | ||
f"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure {name}.", | ||
category=DDTraceDeprecationWarning, | ||
removal_version="3.0.0", | ||
) | ||
|
||
if name in globals(): | ||
return globals()[name] | ||
raise AttributeError("%s has no attribute %s", __name__, name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.