From 02ba09cda2c808d28606666f726d950ebe39e03c Mon Sep 17 00:00:00 2001 From: Daniel Szoke <7881302+szokeasaurusrex@users.noreply.github.com> Date: Fri, 4 Oct 2024 11:28:36 +0200 Subject: [PATCH] docs: Update FastAPI/Starlette `failed_request_status_codes` docs (#11435) We have slightly changed the `failed_request_status_codes` API for FastAPI and Starlette in https://github.com/getsentry/sentry-python/pull/3563. The old API is still supported, but it is deprecated, so the docs should only document the new API. --- .../python/integrations/fastapi/index.mdx | 16 ++++++++-------- .../python/integrations/starlette/index.mdx | 14 +++++++------- 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/docs/platforms/python/integrations/fastapi/index.mdx b/docs/platforms/python/integrations/fastapi/index.mdx index d9cffc54ca305..4235e97c77f15 100644 --- a/docs/platforms/python/integrations/fastapi/index.mdx +++ b/docs/platforms/python/integrations/fastapi/index.mdx @@ -81,12 +81,12 @@ sentry_sdk.init( integrations=[ StarletteIntegration( transaction_style="endpoint", - failed_request_status_codes=[403, range(500, 599)], + failed_request_status_codes={403, *range(500, 599)}, http_methods_to_capture=("GET",), ), FastApiIntegration( transaction_style="endpoint", - failed_request_status_codes=[403, range(500, 599)], + failed_request_status_codes={403, *range(500, 599)}, http_methods_to_capture=("GET",), ), ] @@ -132,16 +132,16 @@ You can pass the following keyword arguments to `StarletteIntegration()` and `Fa - `failed_request_status_codes`: - A list of integers or containers (objects that allow membership checks via `in`) - of integers that will determine which status codes should be reported to Sentry. + A `set` of integers that will determine which status codes should be reported to Sentry. Examples of valid `failed_request_status_codes`: - - `[500]` will only send events on HTTP 500. - - `[400, range(500, 599)]` will send events on HTTP 400 as well as the 500-599 range. - - `[500, 503]` will send events on HTTP 500 and 503. + - `{500}` will only send events on HTTP 500. + - `{400, *range(500, 600)}` will send events on HTTP 400 as well as the 5xx range. + - `{500, 503}` will send events on HTTP 500 and 503. + - `set()` (the empty set) will not send events for any HTTP status code. - The default is `[range(500, 599)]`. + The default is `{*range(500, 600)}`, meaning that all 5xx status codes are reported to Sentry. - `http_methods_to_capture`: diff --git a/docs/platforms/python/integrations/starlette/index.mdx b/docs/platforms/python/integrations/starlette/index.mdx index 06961d69f9394..d370efa1f2dcc 100644 --- a/docs/platforms/python/integrations/starlette/index.mdx +++ b/docs/platforms/python/integrations/starlette/index.mdx @@ -59,7 +59,7 @@ sentry_sdk.init( integrations=[ StarletteIntegration( transaction_style="endpoint", - failed_request_status_codes=[403, range(500, 599)], + failed_request_status_codes={403, *range(500, 599)}, middleware_spans=False, http_methods_to_capture=("GET",), ) @@ -89,16 +89,16 @@ You can pass the following keyword arguments to `StarletteIntegration()`: - `failed_request_status_codes`: - A list of integers or containers (objects that allow membership checks via `in`) - of integers that will determine which status codes should be reported to Sentry. + A `set` of integers that will determine which status codes should be reported to Sentry. Examples of valid `failed_request_status_codes`: - - `[500]` will only send events on HTTP 500. - - `[400, range(500, 599)]` will send events on HTTP 400 as well as the 500-599 range. - - `[500, 503]` will send events on HTTP 500 and 503. + - `{500}` will only send events on HTTP 500. + - `{400, *range(500, 600)}` will send events on HTTP 400 as well as the 5xx range. + - `{500, 503}` will send events on HTTP 500 and 503. + - `set()` (the empty set) will not send events for any HTTP status code. - The default is `[range(500, 599)]`. + The default is `{*range(500, 600)}`, meaning that all 5xx status codes are reported to Sentry. - `middleware_spans`: