Skip to content

Commit 6b84fcb

Browse files
authored
docs: Document failed_request_status_codes for Litestar integration (#12604)
1 parent 415d790 commit 6b84fcb

File tree

1 file changed

+34
-0
lines changed
  • docs/platforms/python/integrations/litestar

1 file changed

+34
-0
lines changed

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,40 @@ When you point your browser to [http://localhost:8000/hello](http://localhost:80
7373

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

76+
## Options
77+
78+
By adding `LitestarIntegration` to your `sentry_sdk.init()` call explicitly, you can set options for `LitestarIntegration` to change its behavior:
79+
80+
```python
81+
import sentry_sdk
82+
from sentry_sdk.integrations.litestar import LitestarIntegration
83+
84+
sentry_sdk.init(
85+
# ...
86+
integrations=[
87+
LitestarIntegration(
88+
failed_request_status_codes={403, *range(500, 599)},
89+
),
90+
],
91+
)
92+
```
93+
94+
You can pass the following keyword arguments to `LitestarIntegration()`:
95+
96+
### `failed_request_status_codes`
97+
98+
A `set` of integers that will determine when an `HTTPException` should be reported to Sentry. The `HTTPException` is reported to Sentry if its status code is contained in the `failed_request_status_codes` set.
99+
100+
Examples of valid `failed_request_status_codes`:
101+
102+
- `{500}` will only report `HTTPException` with status 500.
103+
- `{400, *range(500, 600)}` will report `HTTPException` with status 400 as well as those in the 5xx range.
104+
- `set()` (the empty set) will not report any `HTTPException` to Sentry.
105+
106+
The default is `{*range(500, 600)}`, meaning that any `HTTPException` with a status in the 5xx range is reported to Sentry.
107+
108+
Regardless of how `failed_request_status_codes` is set, any exceptions raised by the handler, which are not of type `HTTPException` (or a subclass) are reported to Sentry. For example, if your request handler raises an unhandled `AttributeError`, the `AttributeError` gets reported to Sentry, even if you have set `failed_request_status_codes=set()`.
109+
76110
## Supported Versions
77111

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

0 commit comments

Comments
 (0)