You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/platforms/python/guides/tornado/index.mdx
+42-11Lines changed: 42 additions & 11 deletions
Original file line number
Diff line number
Diff line change
@@ -6,14 +6,14 @@ redirect_from:
6
6
description: "Learn about using Sentry with Tornado."
7
7
---
8
8
9
-
The Tornado integration adds support for the [Tornado Web Framework](https://www.tornadoweb.org/). A Tornado version of 5 or greater and Python 3.6 or greater is required.
9
+
The Tornado integration adds support for the [Tornado Web Framework](https://www.tornadoweb.org/).
10
10
11
11
## Install
12
12
13
-
Install `sentry-sdk` from PyPI:
13
+
Install `sentry-sdk` from PyPI with the `tornado` extra:
14
14
15
15
```bash
16
-
pip install --upgrade sentry-sdk
16
+
pip install --upgrade sentry-sdk[tornado]
17
17
```
18
18
19
19
If you're on Python 3.6, you also need the `aiocontextvars` package:
@@ -34,22 +34,48 @@ from sentry_sdk.integrations.tornado import TornadoIntegration
34
34
35
35
sentry_sdk.init(
36
36
dsn="___PUBLIC_DSN___",
37
-
integrations=[
38
-
TornadoIntegration(),
39
-
],
40
-
41
37
# Set traces_sample_rate to 1.0 to capture 100%
42
38
# of transactions for performance monitoring.
43
-
# We recommend adjusting this value in production,
44
39
traces_sample_rate=1.0,
40
+
integrations=[
41
+
TornadoIntegration(),
42
+
],
45
43
)
46
44
47
-
# Your app code here, without changes
48
-
49
-
classMyHandler(...):
45
+
classMainHandler(tornado.web.RequestHandler):
50
46
# ...
51
47
```
52
48
49
+
## Verify
50
+
51
+
```python
52
+
import asyncio
53
+
import tornado
54
+
55
+
sentry_sdk.init(...) # same as above
56
+
57
+
classMainHandler(tornado.web.RequestHandler):
58
+
defget(self):
59
+
1/0# raises an error
60
+
self.write("Hello, world")
61
+
62
+
defmake_app():
63
+
return tornado.web.Application([
64
+
(r"/", MainHandler),
65
+
])
66
+
67
+
asyncdefmain():
68
+
app = make_app()
69
+
app.listen(8888)
70
+
await asyncio.Event().wait()
71
+
72
+
asyncio.run(main())
73
+
```
74
+
75
+
When you point your browser to [http://localhost:8888/](http://localhost:8888/) a transaction in the Performance section of [sentry.io](https://sentry.io) will be created. Additionally, an error event will be sent to [sentry.io](https://sentry.io) and will be connected to the transaction.
76
+
77
+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
78
+
53
79
## Behavior
54
80
55
81
- The Tornado integration will be installed for all of your apps and handlers.
@@ -63,3 +89,8 @@ class MyHandler(...):
63
89
- Logging with any logger will create breadcrumbs when
0 commit comments