Skip to content

Commit 514d1dc

Browse files
dd-octo-sts[bot]mabdinurbrettlangdon
authored
chore(tornado): v4.0 deprecations [backport 4.0] (#15304)
Backport 75a19c2 from #15274 to 4.0. ## Description Deprecated Tornado versions older than v6.1 and programmatic configuration via ddtrace.contrib.tornado. Users should upgrade to Tornado v6.1+ and use environment variables with import ddtrace.auto. ## Motivation Tornado v6.1 (released in 2020) added contextvars support, eliminating the need for a custom Tornado Context Provider. This allows us to remove the last integration specific Context Provider and simplify our context API. Co-authored-by: Munir Abdinur <munir.abdinur@datadoghq.com> Co-authored-by: Brett Langdon <brett.langdon@datadoghq.com>
1 parent 29a1f9f commit 514d1dc

File tree

4 files changed

+32
-1
lines changed

4 files changed

+32
-1
lines changed

ddtrace/contrib/internal/tornado/patch.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@
77
import ddtrace
88
from ddtrace import config
99
from ddtrace.contrib.internal.tornado.stack_context import context_provider
10+
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
1011
from ddtrace.internal.utils.formats import asbool
1112
from ddtrace.internal.utils.wrappers import unwrap as _u
13+
from ddtrace.vendor.debtcollector import deprecate
1214

1315
from . import application
1416
from . import decorators
@@ -26,7 +28,19 @@
2628

2729
def get_version():
2830
# type: () -> str
29-
return getattr(tornado, "version", "")
31+
return getattr(tornado, "version", "0.0.0")
32+
33+
34+
VERSION_TUPLE = tuple([int(x) for x in get_version().split(".")])
35+
36+
if VERSION_TUPLE < (6, 1, 0):
37+
deprecate(
38+
f"Tornado {VERSION_TUPLE} is deprecated",
39+
message="Use Tornado v6.1 or later and configure tracing using "
40+
"environment variables and ``ddtrace-run`` or ``import ddtrace.auto`` instead.",
41+
category=DDTraceDeprecationWarning,
42+
removal_version="4.0.0",
43+
)
3044

3145

3246
def _supported_versions() -> Dict[str, str]:

ddtrace/contrib/tornado.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,17 @@ def log_exception(self, typ, value, tb):
100100
from ddtrace.contrib.internal.tornado.stack_context import TracerStackContext
101101
from ddtrace.contrib.internal.tornado.stack_context import context_provider
102102
from ddtrace.contrib.internal.tornado.stack_context import run_with_trace_context
103+
from ddtrace.internal.utils.deprecations import DDTraceDeprecationWarning
104+
from ddtrace.vendor.debtcollector import deprecate
103105

104106

107+
deprecate(
108+
"ddtrace.contrib.tornado is deprecated",
109+
message="Use ``import ddtrace.auto`` and ``DD_PATCH_MODULES`` to configure tracing for Tornado.",
110+
category=DDTraceDeprecationWarning,
111+
removal_version="4.0.0",
112+
)
113+
105114
__all__ = [
106115
"context_provider",
107116
"run_with_trace_context",
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
deprecations:
3+
- |
4+
tornado: Deprecated support for Tornado versions older than v6.1. Use Tornado v6.1 or later.
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
---
2+
deprecations:
3+
- |
4+
tornado: Deprecates programmatic tracing configuration via the ``ddtrace.contrib.tornado`` module. Configure tracing using environment variables and ``import ddtrace.auto`` instead.

0 commit comments

Comments
 (0)