Skip to content

Commit

Permalink
docs: Document aiohttp failed_request_status_codes (#11433)
Browse files Browse the repository at this point in the history
Document the Python SDK aiohttp integration's new failed_request_status_codes option.

Closes #11417
  • Loading branch information
szokeasaurusrex authored Oct 4, 2024
1 parent f631c13 commit db77e2d
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion docs/platforms/python/integrations/aiohttp/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,8 @@ sentry_sdk.init(
# same as above
integrations=[
AioHttpIntegration(
transaction_style="method_and_path_pattern",
transaction_style="...", # type: str
failed_request_status_codes={...} # type: collections.abc.Set[int]
),
],
)
Expand All @@ -84,6 +85,21 @@ Configure the way Sentry names transactions:

The default is `"handler_name"`.

### `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 (i.e. `HTTPInternalServerError`).
- `{400, *range(500, 600)}` will report `HTTPException` with status 400 (i.e. `HTTPBadRequest`) 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

- AIOHTTP: 3.5+
Expand Down

0 comments on commit db77e2d

Please sign in to comment.