Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(python): Add failed_request_status_codes to integrations #10282

Merged
merged 1 commit into from
Jun 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 18 additions & 3 deletions docs/platforms/python/integrations/fastapi/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ It takes a couple of moments for the data to appear in [sentry.io](https://sentr

The following information about your FastAPI project will be available to you on Sentry.io:

- All exceptions leading to an Internal Server Error are captured and reported.
- By default, all exceptions leading to an Internal Server Error are captured and reported. The HTTP status codes to report on are configurable via the `failed_request_status_codes` [option](#options).
- Request data such as URL, HTTP method, headers, form data, and JSON payloads is attached to all issues.
- Sentry excludes raw bodies and multipart file uploads.
- Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set `send_default_pii` to `True`.
Expand Down Expand Up @@ -80,10 +80,12 @@ sentry_sdk.init(
# same as above
integrations=[
StarletteIntegration(
transaction_style="endpoint"
transaction_style="endpoint",
failed_request_status_codes=[403, range(500, 599)],
),
FastApiIntegration(
transaction_style="endpoint"
transaction_style="endpoint",
failed_request_status_codes=[403, range(500, 599)],
),
]
)
Expand Down Expand Up @@ -126,6 +128,19 @@ You can pass the following keyword arguments to `StarletteIntegration()` and `Fa

The default is `"url"`.

- `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.

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.

The default is `[range(500, 599)]`.

## Supported Versions

- FastAPI: 0.79.0+
Expand Down
16 changes: 15 additions & 1 deletion docs/platforms/python/integrations/starlette/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ It takes a couple of moments for the data to appear in [sentry.io](https://sentr

## Behavior

- All exceptions leading to an Internal Server Error are reported.
- By default, all exceptions leading to an Internal Server Error are reported. The HTTP status codes to report on are configurable via the `failed_request_status_codes` [option](#options).

- Request data is attached to all events: **HTTP method, URL, headers, form data, JSON payloads**. Sentry excludes raw bodies and multipart file uploads. Sentry also excludes personally identifiable information (such as user ids, usernames, cookies, authorization headers, IP addresses) unless you set `send_default_pii` to `True`.

Expand All @@ -59,6 +59,7 @@ sentry_sdk.init(
integrations=[
StarletteIntegration(
transaction_style="endpoint",
failed_request_status_codes=[403, range(500, 599)],
)
],
)
Expand All @@ -84,6 +85,19 @@ You can pass the following keyword arguments to `StarletteIntegration()`:

The default is `"url"`.

- `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.

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.

The default is `[range(500, 599)]`.

## Supported Versions

- Starlette: 0.19.1+
Expand Down
Loading