Skip to content

Commit 2f862fe

Browse files
authored
chore(tornado): drop support for <6.1 (#15369)
## Description Drops support for Tornado versions less than 6.1. The minimum supported version is now Tornado >=6.1, which is asyncio-based. Updated tests and documentation to reflect this change. ## Testing Updated Tornado integration tests to only run against Tornado >=6.1. All existing tests pass with the new minimum version requirement. ## Risks Low. Tornado v6.1 was released in 2020 and has been stable. Users on older versions will need to upgrade to continue using the integration. ## Additional Notes - Updated `_supported_versions()` to reflect the new minimum version requirement - Updated documentation to specify Tornado >=6.1 support - Updated test matrix in `riotfile.py` to remove older Tornado versions
1 parent ffa75d3 commit 2f862fe

File tree

19 files changed

+119
-278
lines changed

19 files changed

+119
-278
lines changed

.riot/requirements/1099f43.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

.riot/requirements/116a9e0.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

.riot/requirements/17298d6.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

.riot/requirements/18f2a74.txt

Lines changed: 0 additions & 20 deletions
This file was deleted.

.riot/requirements/1d03e99.txt

Lines changed: 0 additions & 22 deletions
This file was deleted.

.riot/requirements/aaa8f63.txt renamed to .riot/requirements/1da9e5b.txt

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,10 @@
22
# This file is autogenerated by pip-compile with Python 3.9
33
# by the following command:
44
#
5-
# pip-compile --allow-unsafe --no-annotate --resolver=backtracking .riot/requirements/aaa8f63.in
5+
# pip-compile --allow-unsafe --no-annotate .riot/requirements/1da9e5b.in
66
#
7-
attrs==25.3.0
8-
coverage[toml]==7.8.2
7+
attrs==25.4.0
8+
coverage[toml]==7.10.7
99
exceptiongroup==1.3.0
1010
hypothesis==6.45.0
1111
importlib-metadata==8.7.0
@@ -15,11 +15,11 @@ opentracing==2.4.0
1515
packaging==25.0
1616
pluggy==1.6.0
1717
pytest==8.0.0
18-
pytest-cov==6.1.1
19-
pytest-mock==3.14.1
20-
pytest-randomly==3.16.0
18+
pytest-cov==7.0.0
19+
pytest-mock==3.15.1
20+
pytest-randomly==4.0.1
2121
sortedcontainers==2.4.0
22-
tomli==2.2.1
23-
tornado==6.0.4
24-
typing-extensions==4.14.0
22+
tomli==2.3.0
23+
tornado==6.1
24+
typing-extensions==4.15.0
2525
zipp==3.23.0

.riot/requirements/2249718.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.

ddtrace/contrib/integration_registry/registry.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -874,7 +874,7 @@ integrations:
874874
- tornado
875875
tested_versions_by_dependency:
876876
tornado:
877-
min: 6.0.4
877+
min: "6.1"
878878
max: 6.5.1
879879

880880
- integration_name: unittest
Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
r"""
2+
The Tornado integration traces all ``RequestHandler`` defined in a Tornado web application.
3+
Auto instrumentation is available using the ``patch`` function that **must be called before**
4+
importing the tornado library.
5+
6+
This integration supports Tornado >=6.1, which is asyncio-based. The integration properly
7+
handles async/await coroutines and functions that return Futures, ensuring accurate span
8+
durations and correct context propagation.
9+
10+
The following is an example::
11+
12+
# patch before importing tornado and concurrent.futures
13+
import asyncio
14+
import tornado.web
15+
import tornado.httpserver
16+
17+
class MainHandler(tornado.web.RequestHandler):
18+
def get(self):
19+
self.write("Hello, world")
20+
21+
async def main():
22+
app = tornado.web.Application([
23+
(r"/", MainHandler),
24+
])
25+
server = tornado.httpserver.HTTPServer(app)
26+
server.listen(8888)
27+
28+
# Let the asyncio loop run forever
29+
await asyncio.Event().wait()
30+
31+
if __name__ == "__main__":
32+
asyncio.run(main())
33+
34+
When any type of ``RequestHandler`` is hit, a request root span is automatically created. If
35+
you want to trace more parts of your application, you can use the ``wrap()`` decorator and
36+
the ``trace()`` method as usual::
37+
38+
class MainHandler(tornado.web.RequestHandler):
39+
async def get(self):
40+
await self.notify()
41+
await self.blocking_method()
42+
with tracer.trace('tornado.before_write') as span:
43+
# trace more work in the handler
44+
45+
@tracer.wrap('tornado.executor_handler')
46+
@tornado.concurrent.run_on_executor
47+
def blocking_method(self):
48+
# do something expensive
49+
50+
@tracer.wrap('tornado.notify', service='tornado-notification')
51+
async def notify(self):
52+
# do something
53+
54+
If you are overriding the ``on_finish`` or ``log_exception`` methods on a
55+
``RequestHandler``, you will need to call the super method to ensure the
56+
tracer's patched methods are called::
57+
58+
class MainHandler(tornado.web.RequestHandler):
59+
async def get(self):
60+
self.write("Hello, world")
61+
62+
def on_finish(self):
63+
super(MainHandler, self).on_finish()
64+
# do other clean-up
65+
66+
def log_exception(self, typ, value, tb):
67+
super(MainHandler, self).log_exception(typ, value, tb)
68+
# do other logging
69+
70+
Tornado settings can be used to change some tracing configuration, like::
71+
72+
settings = {
73+
'datadog_trace': {
74+
'default_service': 'my-tornado-app',
75+
'tags': {'env': 'production'},
76+
'distributed_tracing': False,
77+
},
78+
}
79+
80+
app = tornado.web.Application([
81+
(r'/', MainHandler),
82+
], **settings)
83+
84+
The available settings are:
85+
86+
* ``default_service`` (default: `tornado-web`): set the service name used by the tracer. Usually
87+
this configuration must be updated with a meaningful name. Can also be configured via the
88+
``DD_SERVICE`` environment variable.
89+
* ``tags`` (default: `{}`): set global tags that should be applied to all spans.
90+
* ``enabled`` (default: `True`): define if the tracer is enabled or not. If set to `false`, the
91+
code is still instrumented but no spans are sent to the APM agent.
92+
* ``distributed_tracing`` (default: `None`): enable distributed tracing if this is called
93+
remotely from an instrumented application. Overrides the integration config which is configured via the
94+
``DD_TORNADO_DISTRIBUTED_TRACING`` environment variable.
95+
We suggest to enable it only for internal services where headers are under your control.
96+
* ``agent_hostname`` (default: `localhost`): define the hostname of the APM agent.
97+
* ``agent_port`` (default: `8126`): define the port of the APM agent.
98+
* ``settings`` (default: ``{}``): Tracer extra settings used to change, for instance, the filtering behavior.
99+
"""

ddtrace/contrib/internal/tornado/patch.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def get_version():
4444

4545

4646
def _supported_versions() -> Dict[str, str]:
47-
return {"tornado": ">=6.0.0"}
47+
return {"tornado": ">=6.1"}
4848

4949

5050
def patch():

0 commit comments

Comments
 (0)