Skip to content

Commit a5ac206

Browse files
authored
feat(integrations) Add docs for LitestarIntegration (#10880)
1 parent 8b97b0b commit a5ac206

File tree

4 files changed

+96
-2
lines changed

4 files changed

+96
-2
lines changed

docs/platforms/python/integrations/index.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
2323
| <LinkWithPlatformIcon platform="python.sanic" label="Sanic" url="/platforms/python/integrations/sanic" /> ||
2424
| <LinkWithPlatformIcon platform="python.starlette" label="Starlette" url="/platforms/python/integrations/starlette" /> ||
2525
| <LinkWithPlatformIcon platform="python.starlite" label="Starlite" url="/platforms/python/integrations/starlite" /> ||
26+
| <LinkWithPlatformIcon platform="python.litestar" label="Litestar" url="/platforms/python/integrations/litestar" /> ||
2627
| <LinkWithPlatformIcon platform="python.tornado" label="Tornado" url="/platforms/python/integrations/tornado" /> ||
2728

2829
### Databases
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
---
2+
title: Litestar
3+
description: "Learn about using Sentry with Litestar."
4+
---
5+
6+
The Litestar integration adds support for the [Litestar framework](https://docs.litestar.dev/2/).
7+
8+
## Install
9+
10+
Install `sentry-sdk` from PyPI with the `litestar` extra:
11+
12+
```bash
13+
pip install --upgrade 'sentry-sdk[litestar]' uvicorn
14+
```
15+
16+
## Configure
17+
18+
Add `LitestarIntegration()` to your `integrations` list:
19+
20+
<SignInNote />
21+
22+
<OnboardingOptionButtons
23+
options={[
24+
'error-monitoring',
25+
'performance',
26+
'profiling',
27+
]}
28+
/>
29+
30+
```python {"onboardingOptions": {"performance": "6-8", "profiling": "9-12"}}
31+
import sentry_sdk
32+
from sentry_sdk.integrations.litestar import LitestarIntegration
33+
34+
sentry_sdk.init(
35+
dsn="___PUBLIC_DSN___",
36+
# Set traces_sample_rate to 1.0 to capture 100%
37+
# of transactions for tracing.
38+
traces_sample_rate=1.0,
39+
# Set profiles_sample_rate to 1.0 to profile 100%
40+
# of sampled transactions.
41+
# We recommend adjusting this value in production.
42+
profiles_sample_rate=1.0,
43+
integrations=[
44+
LitestarIntegration(),
45+
],
46+
)
47+
```
48+
49+
## Verify
50+
51+
```python
52+
from litestar import Litestar, get
53+
54+
sentry_sdk.init(...) # same as above
55+
56+
@get("/hello")
57+
async def hello_world() -> str:
58+
1 / 0
59+
return "Hello!"
60+
61+
app = Litestar(route_handlers=[hello_world])
62+
```
63+
64+
Save the file above as `app.py` and start the development server with:
65+
66+
```bash
67+
uvicorn app:app
68+
```
69+
70+
When you point your browser to [http://localhost:8000/hello](http://localhost:8000/hello) a transaction will be created in the Performance section of [sentry.io](https://sentry.io). Additionally, the `ZeroDivisionError` we've snuck into our `hello_world` handler will be sent to [sentry.io](https://sentry.io) and will be connected to the transaction.
71+
72+
It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).
73+
74+
## Supported Versions
75+
76+
<Alert level="warning" title="Note">
77+
78+
Litestar was [renamed from Starlite](https://litestar.dev/about/organization.html#litestar-and-starlite)
79+
with the release of version 2.0. We support different integrations for each one. This guide applies to Litestar.
80+
See [Starlite integration](/platforms/python/integrations/starlite) for the guide that applies to Starlite.
81+
82+
</Alert>
83+
84+
- Litestar: 2.0.0+
85+
- Python: 3.8+

docs/platforms/python/integrations/starlite/index.mdx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,8 @@ It takes a couple of moments for the data to appear in [sentry.io](https://sentr
4949
<Alert level="warning" title="Note">
5050

5151
Starlite was [renamed to Litestar](https://litestar.dev/about/organization.html#litestar-and-starlite)
52-
with the release of version 2.0. We don't support Litestar yet, so this guide only applies to Starlite 1.51.14
53-
and below.
52+
with the release of version 2.0. We support different integrations for each one. This guide applies to Starlite.
53+
See [Litestar integration](/platforms/python/integrations/litestar) for the guide that applies to Litestar.
5454

5555
</Alert>
5656

src/middleware.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ const USER_DOCS_REDIRECTS: Redirect[] = [
413413
from: '/platforms/python/starlite/',
414414
to: '/platforms/python/integrations/starlite/',
415415
},
416+
{
417+
from: '/clients/python/integrations/litestar/',
418+
to: '/platforms/python/integrations/litestar/',
419+
},
420+
{
421+
from: '/platforms/python/litestar/',
422+
to: '/platforms/python/integrations/litestar/',
423+
},
416424
{
417425
from: '/platforms/python/beam/',
418426
to: '/platforms/python/integrations/beam/',

0 commit comments

Comments
 (0)