Skip to content

feat(python): Add disabled_integrations config option #10808

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

Merged
merged 4 commits into from
Jul 24, 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
6 changes: 5 additions & 1 deletion docs/platforms/python/configuration/options.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -205,9 +205,13 @@ Set this boolean to `False` to disable sending of client reports. Client reports

List of integrations to enable in addition to [auto-enabling integrations](/platforms/python/integrations). This setting can be used to override the default config options for a specific auto-enabling integration or to add an integration that is not auto-enabled.

<ConfigKey name="disabled-integrations" />

List of integrations that will be disabled. This setting can be used to explicitly turn off specific [auto-enabling](/platforms/python/integrations/#available-integrations) or [default](/platforms/python/integrations/default-integrations/) integrations.

<ConfigKey name="auto-enabling-integrations" />

Configures whether [auto-enabling integrations](/platforms/python/integrations/default-integrations/) should be enabled. The default is `True`.
Configures whether [auto-enabling integrations](/platforms/python/integrations/#available-integrations) should be enabled. The default is `True`.

When set to `False`, no auto-enabling integrations will be enabled by default, even if the corresponding framework/library is detected.

Expand Down
28 changes: 21 additions & 7 deletions docs/platforms/python/integrations/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -151,19 +151,33 @@ sentry_sdk.init(

### Disabling Integrations

There are two types of integrations that are added automatically:
To disable an integration, use the [`disabled_integrations`](/platforms/python/configuration/options/#disabled-integrations) config option:

```python
import sentry_sdk
from sentry_sdk.integrations.flask import FlaskIntegration

sentry_sdk.init(
# Do not use the Flask integration even if Flask is installed.
disabled_integrations=[
FlaskIntegration(),
],
)
```

It's also possible to disable all automatically-added integrations. There are two types:

* **Auto-enabled integrations** like `FlaskIntegration` are automatically added
if the SDK detects that you have a corresponding package (like Flask) installed.
This happens when the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option is set to
`True` (default).
* **Default integrations** like `logging` or `excepthook` are always enabled,
regardless of what packages you have installed, as long as the
[`default_integrations`](/platforms/python/configuration/options/#default-integrations) option is `True` (default). They provide essential
SDK functionality like error deduplication or event flushing at interpreter
shutdown.
* **Auto-enabling integrations** like `FlaskIntegration` are automatically added
if the SDK detects you have the corresponding package (like Flask) installed.
This happens as long as the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option is set to
`True` (default).

To disable a specific auto-enabling integration, first disable all auto-enabling integrations by setting the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option to `False`. Then, explicitly enable all the auto-enabling integrations you wish to use by setting the [`integrations`](/platforms/python/configuration/options/#integrations) configuration option.
To disable all auto-enabling integrations, you can use the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option:

```python
import sentry_sdk
Expand All @@ -178,7 +192,7 @@ sentry_sdk.init(
)
```

To disable one of the [default integrations](default-integrations/),
To disable all [default integrations](default-integrations/),
set [`default_integrations`](/platforms/python/configuration/options/#default-integrations) to `False`. Note that this disables _all_ automatically
added integrations, both default and auto-enabling. Any integrations you want to use
then have to be manually specified via the [`integrations`](/platforms/python/configuration/options/#integrations) config option.
Expand Down
Loading