Skip to content

Commit bf21e6f

Browse files
antonpirkergetsantry[bot]shanamatthews
authored
Python: Getting Started tornado (#7831)
* Python: Getting Started tornado * style(lint): Auto commit lint changes * Update src/platforms/python/guides/tornado/index.mdx Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com> Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
1 parent 9041460 commit bf21e6f

File tree

1 file changed

+42
-11
lines changed

1 file changed

+42
-11
lines changed

src/platforms/python/guides/tornado/index.mdx

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,14 @@ redirect_from:
66
description: "Learn about using Sentry with Tornado."
77
---
88

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/).
1010

1111
## Install
1212

13-
Install `sentry-sdk` from PyPI:
13+
Install `sentry-sdk` from PyPI with the `tornado` extra:
1414

1515
```bash
16-
pip install --upgrade sentry-sdk
16+
pip install --upgrade sentry-sdk[tornado]
1717
```
1818

1919
If you're on Python 3.6, you also need the `aiocontextvars` package:
@@ -34,22 +34,48 @@ from sentry_sdk.integrations.tornado import TornadoIntegration
3434

3535
sentry_sdk.init(
3636
dsn="___PUBLIC_DSN___",
37-
integrations=[
38-
TornadoIntegration(),
39-
],
40-
4137
# Set traces_sample_rate to 1.0 to capture 100%
4238
# of transactions for performance monitoring.
43-
# We recommend adjusting this value in production,
4439
traces_sample_rate=1.0,
40+
integrations=[
41+
TornadoIntegration(),
42+
],
4543
)
4644

47-
# Your app code here, without changes
48-
49-
class MyHandler(...):
45+
class MainHandler(tornado.web.RequestHandler):
5046
# ...
5147
```
5248

49+
## Verify
50+
51+
```python
52+
import asyncio
53+
import tornado
54+
55+
sentry_sdk.init(...) # same as above
56+
57+
class MainHandler(tornado.web.RequestHandler):
58+
def get(self):
59+
1/0 # raises an error
60+
self.write("Hello, world")
61+
62+
def make_app():
63+
return tornado.web.Application([
64+
(r"/", MainHandler),
65+
])
66+
67+
async def main():
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+
5379
## Behavior
5480

5581
- The Tornado integration will be installed for all of your apps and handlers.
@@ -63,3 +89,8 @@ class MyHandler(...):
6389
- Logging with any logger will create breadcrumbs when
6490
the [Logging](/platforms/python/guides/logging/)
6591
integration is enabled (done by default).
92+
93+
## Supported Versions
94+
95+
- Tornado: 5+
96+
- Python: 2.7+

0 commit comments

Comments
 (0)