Skip to content

Commit 88fd5d3

Browse files
committed
chore(tornado): drop support for <v6.1
1 parent 60a975f commit 88fd5d3

25 files changed

+152
-665
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/aaa8f63.txt renamed to .riot/requirements/1b40837.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/1b40837.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.5.2
24+
typing-extensions==4.15.0
2525
zipp==3.23.0

.riot/requirements/1d03e99.txt

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

.riot/requirements/2249718.txt

Lines changed: 0 additions & 24 deletions
This file was deleted.
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+
The following is an example::
7+
8+
# patch before importing tornado and concurrent.futures
9+
from ddtrace.trace import tracer, patch
10+
patch(tornado=True)
11+
12+
import tornado.web
13+
import tornado.gen
14+
import tornado.ioloop
15+
16+
# create your handlers
17+
class MainHandler(tornado.web.RequestHandler):
18+
@tornado.gen.coroutine
19+
def get(self):
20+
self.write("Hello, world")
21+
22+
# create your application
23+
app = tornado.web.Application([
24+
(r'/', MainHandler),
25+
])
26+
27+
# and run it as usual
28+
app.listen(8888)
29+
tornado.ioloop.IOLoop.current().start()
30+
31+
When any type of ``RequestHandler`` is hit, a request root span is automatically created. If
32+
you want to trace more parts of your application, you can use the ``wrap()`` decorator and
33+
the ``trace()`` method as usual::
34+
35+
class MainHandler(tornado.web.RequestHandler):
36+
@tornado.gen.coroutine
37+
def get(self):
38+
yield self.notify()
39+
yield self.blocking_method()
40+
with tracer.trace('tornado.before_write') as span:
41+
# trace more work in the handler
42+
43+
@tracer.wrap('tornado.executor_handler')
44+
@tornado.concurrent.run_on_executor
45+
def blocking_method(self):
46+
# do something expensive
47+
48+
@tracer.wrap('tornado.notify', service='tornado-notification')
49+
@tornado.gen.coroutine
50+
def notify(self):
51+
# do something
52+
53+
If you are overriding the ``on_finish`` or ``log_exception`` methods on a
54+
``RequestHandler``, you will need to call the super method to ensure the
55+
tracer's patched methods are called::
56+
57+
class MainHandler(tornado.web.RequestHandler):
58+
@tornado.gen.coroutine
59+
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/application.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
import ddtrace
66
from ddtrace import config
77
from ddtrace._trace.pin import Pin
8-
from ddtrace.contrib.internal.tornado import decorators
98
from ddtrace.contrib.internal.tornado.constants import CONFIG_KEY
10-
from ddtrace.contrib.internal.tornado.stack_context import context_provider
119
from ddtrace.internal.schema import schematize_service_name
1210

1311

@@ -40,10 +38,8 @@ def tracer_config(__init__, app, args, kwargs):
4038
trace_processors = settings.get("settings", {}).get("FILTERS")
4139

4240
tracer.configure(
43-
context_provider=context_provider,
4441
trace_processors=trace_processors,
4542
)
46-
tracer._wrap_executor = decorators.wrap_executor
4743
# TODO: Remove `enabled`, `hostname` and `port` settings in v4.0
4844
# Tracer should be configured via environment variables
4945
if settings.get("enabled") is not None:

ddtrace/contrib/internal/tornado/decorators.py

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

0 commit comments

Comments
 (0)