Skip to content

Commit a7710e3

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 f631c13 commit a7710e3

File tree

2 files changed

+15
-15
lines changed

2 files changed

+15
-15
lines changed

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -81,12 +81,12 @@ 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
http_methods_to_capture=("GET",),
8686
),
8787
FastApiIntegration(
8888
transaction_style="endpoint",
89-
failed_request_status_codes=[403, range(500, 599)],
89+
failed_request_status_codes={403, *range(500, 599)},
9090
http_methods_to_capture=("GET",),
9191
),
9292
]
@@ -132,16 +132,16 @@ You can pass the following keyword arguments to `StarletteIntegration()` and `Fa
132132

133133
- `failed_request_status_codes`:
134134

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

138137
Examples of valid `failed_request_status_codes`:
139138

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

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

146146
- `http_methods_to_capture`:
147147

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

Lines changed: 7 additions & 7 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
http_methods_to_capture=("GET",),
6565
)
@@ -89,16 +89,16 @@ You can pass the following keyword arguments to `StarletteIntegration()`:
8989

9090
- `failed_request_status_codes`:
9191

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

9594
Examples of valid `failed_request_status_codes`:
9695

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

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

103103
- `middleware_spans`:
104104

0 commit comments

Comments
 (0)