Skip to content

Commit 21439fe

Browse files
committed
try to consolidate deprecation warnings to reduce package size
1 parent 477b6e8 commit 21439fe

File tree

77 files changed

+47
-862
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

77 files changed

+47
-862
lines changed

ddtrace/contrib/__init__.py

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,52 @@
77

88

99
def __getattr__(name):
10-
if name in ("trace_handlers", "func_name", "module_name", "require_modules"):
10+
if name in (
11+
"aiohttp",
12+
"asgi",
13+
"bottle",
14+
"celery",
15+
"cherrypy",
16+
"falcon",
17+
"flask_cache",
18+
"pylibmc",
19+
"pyramid",
20+
"requests",
21+
"sqlalchemy",
22+
"tornado",
23+
"wsgi",
24+
"trace_utils",
25+
"internal",
26+
):
27+
# following attributes are not deprecated
28+
pass
29+
elif name in ("flask_login", "trace_utils_async", "redis_utils", "trace_utils_redis"):
30+
# folowing integrations/utils have unique deprecation messages
31+
pass
32+
elif name in ("trace_handlers", "func_name", "module_name", "require_modules"):
1133
deprecate(
1234
("%s.%s is deprecated" % (__name__, name)),
1335
category=DDTraceDeprecationWarning,
1436
removal_version="3.0.0",
1537
)
38+
elif name in ("aiobotocore", "httplib", "kombu", "snowflake", "sqlalchemy", "tornado", "urllib3"):
39+
# following integrations are not enabled by default and require a unique message
40+
deprecate(
41+
f"{name} is deprecated",
42+
message="Avoid using this package directly. "
43+
f"Set DD_TRACE_{name.upper()}_ENABLED=true and use ``ddtrace.auto`` or the "
44+
"``ddtrace-run`` command to enable and configure this integration.",
45+
category=DDTraceDeprecationWarning,
46+
removal_version="3.0.0",
47+
)
48+
else:
49+
deprecate(
50+
f"{name} is deprecated",
51+
message="Avoid using this package directly. "
52+
f"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure {name}.",
53+
category=DDTraceDeprecationWarning,
54+
removal_version="3.0.0",
55+
)
1656

1757
if name in globals():
1858
return globals()[name]

ddtrace/contrib/aiobotocore/__init__.py

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,15 +38,3 @@
3838

3939
from ddtrace.contrib.internal.aiobotocore.patch import get_version # noqa: F401
4040
from ddtrace.contrib.internal.aiobotocore.patch import patch # noqa: F401
41-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
42-
from ddtrace.vendor.debtcollector import deprecate
43-
44-
45-
deprecate(
46-
("%s is deprecated" % (__name__)),
47-
message="Avoid using this package directly. "
48-
"Set DD_TRACE_AIOBOTOCORE_ENABLED=true and use ``import ddtrace.auto`` or the "
49-
"``ddtrace-run`` command to enable and configure this integration.",
50-
category=DDTraceDeprecationWarning,
51-
removal_version="3.0.0",
52-
)

ddtrace/contrib/aiohttp_jinja2/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -26,14 +26,3 @@
2626
from ddtrace.contrib.internal.aiohttp_jinja2.patch import get_version # noqa: F401
2727
from ddtrace.contrib.internal.aiohttp_jinja2.patch import patch # noqa: F401
2828
from ddtrace.contrib.internal.aiohttp_jinja2.patch import unpatch # noqa: F401
29-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
30-
from ddtrace.vendor.debtcollector import deprecate
31-
32-
33-
deprecate(
34-
("%s is deprecated" % (__name__)),
35-
message="Avoid using this package directly. "
36-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
37-
category=DDTraceDeprecationWarning,
38-
removal_version="3.0.0",
39-
)

ddtrace/contrib/aiomysql/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -48,14 +48,3 @@
4848
from ddtrace.contrib.internal.aiomysql.patch import get_version # noqa: F401
4949
from ddtrace.contrib.internal.aiomysql.patch import patch # noqa: F401
5050
from ddtrace.contrib.internal.aiomysql.patch import unpatch # noqa: F401
51-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
52-
from ddtrace.vendor.debtcollector import deprecate
53-
54-
55-
deprecate(
56-
("%s is deprecated" % (__name__)),
57-
message="Avoid using this package directly. "
58-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
59-
category=DDTraceDeprecationWarning,
60-
removal_version="3.0.0",
61-
)

ddtrace/contrib/aiopg/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,3 @@
2828

2929
from ddtrace.contrib.internal.aiopg.patch import get_version # noqa: F401
3030
from ddtrace.contrib.internal.aiopg.patch import patch # noqa: F401
31-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
32-
from ddtrace.vendor.debtcollector import deprecate
33-
34-
35-
deprecate(
36-
("%s is deprecated" % (__name__)),
37-
message="Avoid using this package directly. "
38-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
39-
category=DDTraceDeprecationWarning,
40-
removal_version="3.0.0",
41-
)

ddtrace/contrib/aioredis/__init__.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -66,18 +66,8 @@
6666
with _w.catch_warnings():
6767
_w.simplefilter("ignore", DeprecationWarning)
6868
# Required to allow users to import from `ddtrace.contrib.aioredis.patch` directly
69-
from . import patch as _ # noqa: F401, I001
69+
from . import patch as _ # noqa: I001,F401
7070

7171
from ddtrace.contrib.internal.aioredis.patch import get_version # noqa: F401
7272
from ddtrace.contrib.internal.aioredis.patch import patch # noqa: F401
7373
from ddtrace.contrib.internal.aioredis.patch import unpatch # noqa: F401
74-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
75-
from ddtrace.vendor.debtcollector import deprecate
76-
77-
78-
deprecate(
79-
"The aioredis integration is deprecated",
80-
message="Please use the redis integration with redis>=4.2.0 instead.",
81-
removal_version="3.0.0",
82-
category=DDTraceDeprecationWarning,
83-
)

ddtrace/contrib/algoliasearch/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,14 +34,3 @@
3434
from ddtrace.contrib.internal.algoliasearch.patch import get_version # noqa: F401
3535
from ddtrace.contrib.internal.algoliasearch.patch import patch # noqa: F401
3636
from ddtrace.contrib.internal.algoliasearch.patch import unpatch # noqa: F401
37-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
38-
from ddtrace.vendor.debtcollector import deprecate
39-
40-
41-
deprecate(
42-
("%s is deprecated" % (__name__)),
43-
message="Avoid using this package directly. "
44-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
45-
category=DDTraceDeprecationWarning,
46-
removal_version="3.0.0",
47-
)

ddtrace/contrib/anthropic/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,3 @@
9494
from ddtrace.contrib.internal.anthropic.patch import get_version # noqa: F401
9595
from ddtrace.contrib.internal.anthropic.patch import patch # noqa: F401
9696
from ddtrace.contrib.internal.anthropic.patch import unpatch # noqa: F401
97-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
98-
from ddtrace.vendor.debtcollector import deprecate
99-
100-
101-
deprecate(
102-
("%s is deprecated" % (__name__)),
103-
message="Avoid using this package directly. "
104-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
105-
category=DDTraceDeprecationWarning,
106-
removal_version="3.0.0",
107-
)

ddtrace/contrib/aredis/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,3 @@ async def example():
7777

7878
from ddtrace.contrib.internal.aredis.patch import get_version # noqa: F401
7979
from ddtrace.contrib.internal.aredis.patch import patch # noqa: F401
80-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
81-
from ddtrace.vendor.debtcollector import deprecate
82-
83-
84-
deprecate(
85-
("%s is deprecated" % (__name__)),
86-
message="Avoid using this package directly. "
87-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
88-
category=DDTraceDeprecationWarning,
89-
removal_version="3.0.0",
90-
)

ddtrace/contrib/asyncio/__init__.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,6 @@
1717
from ddtrace.contrib.internal.asyncio.patch import get_version # noqa: F401
1818
from ddtrace.contrib.internal.asyncio.patch import patch # noqa: F401
1919
from ddtrace.contrib.internal.asyncio.patch import unpatch # noqa: F401
20-
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
21-
from ddtrace.vendor.debtcollector import deprecate
2220

2321

2422
context_provider = DefaultContextProvider()
25-
26-
27-
deprecate(
28-
("%s is deprecated" % (__name__)),
29-
message="Avoid using this package directly. "
30-
"Use ``import ddtrace.auto`` or the ``ddtrace-run`` command to enable and configure this integration.",
31-
category=DDTraceDeprecationWarning,
32-
removal_version="3.0.0",
33-
)

0 commit comments

Comments
 (0)