Skip to content

Commit 12dd357

Browse files
sentrivanalizokm
andauthored
feat(python): Add disabled_integrations config option (#10808)
--------- Co-authored-by: Liza Mock <[email protected]>
1 parent 05ba44d commit 12dd357

File tree

2 files changed

+26
-8
lines changed

2 files changed

+26
-8
lines changed

docs/platforms/python/configuration/options.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,13 @@ Set this boolean to `False` to disable sending of client reports. Client reports
205205

206206
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.
207207

208+
<ConfigKey name="disabled-integrations" />
209+
210+
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.
211+
208212
<ConfigKey name="auto-enabling-integrations" />
209213

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

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

docs/platforms/python/integrations/index.mdx

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -151,19 +151,33 @@ sentry_sdk.init(
151151

152152
### Disabling Integrations
153153

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

156+
```python
157+
import sentry_sdk
158+
from sentry_sdk.integrations.flask import FlaskIntegration
159+
160+
sentry_sdk.init(
161+
# Do not use the Flask integration even if Flask is installed.
162+
disabled_integrations=[
163+
FlaskIntegration(),
164+
],
165+
)
166+
```
167+
168+
It's also possible to disable all automatically-added integrations. There are two types:
169+
170+
* **Auto-enabled integrations** like `FlaskIntegration` are automatically added
171+
if the SDK detects that you have a corresponding package (like Flask) installed.
172+
This happens when the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option is set to
173+
`True` (default).
156174
* **Default integrations** like `logging` or `excepthook` are always enabled,
157175
regardless of what packages you have installed, as long as the
158176
[`default_integrations`](/platforms/python/configuration/options/#default-integrations) option is `True` (default). They provide essential
159177
SDK functionality like error deduplication or event flushing at interpreter
160178
shutdown.
161-
* **Auto-enabling integrations** like `FlaskIntegration` are automatically added
162-
if the SDK detects you have the corresponding package (like Flask) installed.
163-
This happens as long as the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option is set to
164-
`True` (default).
165179

166-
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.
180+
To disable all auto-enabling integrations, you can use the [`auto_enabling_integrations`](/platforms/python/configuration/options/#auto-enabling-integrations) option:
167181

168182
```python
169183
import sentry_sdk
@@ -178,7 +192,7 @@ sentry_sdk.init(
178192
)
179193
```
180194

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

0 commit comments

Comments
 (0)