Skip to content

Commit 41ac2f4

Browse files
docs: Update FastAPI/Starlette failed_request_status_codes docs
We have slightly changed the `failed_request_status_codes` API for FastAPI and Starlette in getsentry/sentry-python#3563. The old API is still supported, but it is deprecated, so the docs should only document the new API.
1 parent 40bfe16 commit 41ac2f4

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,11 @@ sentry_sdk.init(
8181
integrations=[
8282
StarletteIntegration(
8383
transaction_style="endpoint",
84-
failed_request_status_codes=[403, range(500, 599)],
84+
failed_request_status_codes={403, *range(500, 599)},
8585
),
8686
FastApiIntegration(
8787
transaction_style="endpoint",
88-
failed_request_status_codes=[403, range(500, 599)],
88+
failed_request_status_codes={403, *range(500, 599)},
8989
),
9090
]
9191
)
@@ -130,16 +130,16 @@ You can pass the following keyword arguments to `StarletteIntegration()` and `Fa
130130

131131
- `failed_request_status_codes`:
132132

133-
A list of integers or containers (objects that allow membership checks via `in`)
134-
of integers that will determine which status codes should be reported to Sentry.
133+
A `set` of integers that will determine which status codes should be reported to Sentry.
135134

136135
Examples of valid `failed_request_status_codes`:
137136

138-
- `[500]` will only send events on HTTP 500.
139-
- `[400, range(500, 599)]` will send events on HTTP 400 as well as the 500-599 range.
140-
- `[500, 503]` will send events on HTTP 500 and 503.
137+
- `{500}` will only send events on HTTP 500.
138+
- `{400, *range(500, 600)}` will send events on HTTP 400 as well as the 5xx range.
139+
- `{500, 503}` will send events on HTTP 500 and 503.
140+
- `set()` (the empty set) will not send events for any HTTP status code.
141141

142-
The default is `[range(500, 599)]`.
142+
The default is `{*range(500, 600)}`, meaning that all 5xx status codes are reported to Sentry.
143143

144144
## Supported Versions
145145

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ sentry_sdk.init(
5959
integrations=[
6060
StarletteIntegration(
6161
transaction_style="endpoint",
62-
failed_request_status_codes=[403, range(500, 599)],
62+
failed_request_status_codes={403, *range(500, 599)},
6363
middleware_spans=False,
6464
)
6565
],
@@ -86,18 +86,18 @@ You can pass the following keyword arguments to `StarletteIntegration()`:
8686

8787
The default is `"url"`.
8888

89-
- `failed_request_status_codes`:
89+
- `failed_request_status_codes`:
9090

91-
A list of integers or containers (objects that allow membership checks via `in`)
92-
of integers that will determine which status codes should be reported to Sentry.
91+
A `set` of integers that will determine which status codes should be reported to Sentry.
9392

9493
Examples of valid `failed_request_status_codes`:
9594

96-
- `[500]` will only send events on HTTP 500.
97-
- `[400, range(500, 599)]` will send events on HTTP 400 as well as the 500-599 range.
98-
- `[500, 503]` will send events on HTTP 500 and 503.
95+
- `{500}` will only send events on HTTP 500.
96+
- `{400, *range(500, 600)}` will send events on HTTP 400 as well as the 5xx range.
97+
- `{500, 503}` will send events on HTTP 500 and 503.
98+
- `set()` (the empty set) will not send events for any HTTP status code.
9999

100-
The default is `[range(500, 599)]`.
100+
The default is `{*range(500, 600)}`, meaning that all 5xx status codes are reported to Sentry.
101101

102102
- `middleware_spans`:
103103

0 commit comments

Comments
 (0)