Skip to content

Commit db77e2d

Browse files
docs: Document aiohttp failed_request_status_codes (#11433)
Document the Python SDK aiohttp integration's new failed_request_status_codes option. Closes #11417
1 parent f631c13 commit db77e2d

File tree

1 file changed

+17
-1
lines changed
  • docs/platforms/python/integrations/aiohttp

1 file changed

+17
-1
lines changed

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

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,8 @@ sentry_sdk.init(
6767
# same as above
6868
integrations=[
6969
AioHttpIntegration(
70-
transaction_style="method_and_path_pattern",
70+
transaction_style="...", # type: str
71+
failed_request_status_codes={...} # type: collections.abc.Set[int]
7172
),
7273
],
7374
)
@@ -84,6 +85,21 @@ Configure the way Sentry names transactions:
8485

8586
The default is `"handler_name"`.
8687

88+
### `failed_request_status_codes`
89+
90+
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.
91+
92+
Examples of valid `failed_request_status_codes`:
93+
94+
- `{500}` will only report `HTTPException` with status 500 (i.e. `HTTPInternalServerError`).
95+
- `{400, *range(500, 600)}` will report `HTTPException` with status 400 (i.e. `HTTPBadRequest`) as well as those in the 5xx range.
96+
- `set()` (the empty set) will not report any `HTTPException` to Sentry.
97+
98+
The default is `{*range(500, 600)}`, meaning that any `HTTPException` with a status in the 5xx range is reported to Sentry.
99+
100+
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()`.
101+
102+
87103
## Supported Versions
88104

89105
- AIOHTTP: 3.5+

0 commit comments

Comments
 (0)