Skip to content

Commit

Permalink
feat(integrations) Add docs for LitestarIntegration (#10880)
Browse files Browse the repository at this point in the history
  • Loading branch information
KellyWalker authored Aug 13, 2024
1 parent 8b97b0b commit a5ac206
Show file tree
Hide file tree
Showing 4 changed files with 96 additions and 2 deletions.
1 change: 1 addition & 0 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra
| <LinkWithPlatformIcon platform="python.sanic" label="Sanic" url="/platforms/python/integrations/sanic" /> ||
| <LinkWithPlatformIcon platform="python.starlette" label="Starlette" url="/platforms/python/integrations/starlette" /> ||
| <LinkWithPlatformIcon platform="python.starlite" label="Starlite" url="/platforms/python/integrations/starlite" /> ||
| <LinkWithPlatformIcon platform="python.litestar" label="Litestar" url="/platforms/python/integrations/litestar" /> ||
| <LinkWithPlatformIcon platform="python.tornado" label="Tornado" url="/platforms/python/integrations/tornado" /> ||

### Databases
Expand Down
85 changes: 85 additions & 0 deletions docs/platforms/python/integrations/litestar/index.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
---
title: Litestar
description: "Learn about using Sentry with Litestar."
---

The Litestar integration adds support for the [Litestar framework](https://docs.litestar.dev/2/).

## Install

Install `sentry-sdk` from PyPI with the `litestar` extra:

```bash
pip install --upgrade 'sentry-sdk[litestar]' uvicorn
```

## Configure

Add `LitestarIntegration()` to your `integrations` list:

<SignInNote />

<OnboardingOptionButtons
options={[
'error-monitoring',
'performance',
'profiling',
]}
/>

```python {"onboardingOptions": {"performance": "6-8", "profiling": "9-12"}}
import sentry_sdk
from sentry_sdk.integrations.litestar import LitestarIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
# Set traces_sample_rate to 1.0 to capture 100%
# of transactions for tracing.
traces_sample_rate=1.0,
# Set profiles_sample_rate to 1.0 to profile 100%
# of sampled transactions.
# We recommend adjusting this value in production.
profiles_sample_rate=1.0,
integrations=[
LitestarIntegration(),
],
)
```

## Verify

```python
from litestar import Litestar, get

sentry_sdk.init(...) # same as above

@get("/hello")
async def hello_world() -> str:
1 / 0
return "Hello!"

app = Litestar(route_handlers=[hello_world])
```

Save the file above as `app.py` and start the development server with:

```bash
uvicorn app:app
```

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.

It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## Supported Versions

<Alert level="warning" title="Note">

Litestar was [renamed from Starlite](https://litestar.dev/about/organization.html#litestar-and-starlite)
with the release of version 2.0. We support different integrations for each one. This guide applies to Litestar.
See [Starlite integration](/platforms/python/integrations/starlite) for the guide that applies to Starlite.

</Alert>

- Litestar: 2.0.0+
- Python: 3.8+
4 changes: 2 additions & 2 deletions docs/platforms/python/integrations/starlite/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@ It takes a couple of moments for the data to appear in [sentry.io](https://sentr
<Alert level="warning" title="Note">

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

</Alert>

Expand Down
8 changes: 8 additions & 0 deletions src/middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,14 @@ const USER_DOCS_REDIRECTS: Redirect[] = [
from: '/platforms/python/starlite/',
to: '/platforms/python/integrations/starlite/',
},
{
from: '/clients/python/integrations/litestar/',
to: '/platforms/python/integrations/litestar/',
},
{
from: '/platforms/python/litestar/',
to: '/platforms/python/integrations/litestar/',
},
{
from: '/platforms/python/beam/',
to: '/platforms/python/integrations/beam/',
Expand Down

0 comments on commit a5ac206

Please sign in to comment.