diff --git a/docs/platforms/python/integrations/litestar/index.mdx b/docs/platforms/python/integrations/litestar/index.mdx index 884fab4dfa2dc..fabb689ca48ca 100644 --- a/docs/platforms/python/integrations/litestar/index.mdx +++ b/docs/platforms/python/integrations/litestar/index.mdx @@ -73,6 +73,40 @@ When you point your browser to [http://localhost:8000/hello](http://localhost:80 It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io). +## Options + +By adding `LitestarIntegration` to your `sentry_sdk.init()` call explicitly, you can set options for `LitestarIntegration` to change its behavior: + +```python +import sentry_sdk +from sentry_sdk.integrations.litestar import LitestarIntegration + +sentry_sdk.init( + # ... + integrations=[ + LitestarIntegration( + failed_request_status_codes={403, *range(500, 599)}, + ), + ], +) +``` + +You can pass the following keyword arguments to `LitestarIntegration()`: + +### `failed_request_status_codes` + +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. + +Examples of valid `failed_request_status_codes`: + +- `{500}` will only report `HTTPException` with status 500. +- `{400, *range(500, 600)}` will report `HTTPException` with status 400 as well as those in the 5xx range. +- `set()` (the empty set) will not report any `HTTPException` to Sentry. + +The default is `{*range(500, 600)}`, meaning that any `HTTPException` with a status in the 5xx range is reported to Sentry. + +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()`. + ## Supported Versions