You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 05346fb
Browse filesBrowse the repository at this point in the historyBrowse files
Leave sentry-sdk's auto-enabling integrations off while Sentry tracing is off (#363)
Adds sentry_auto_enabling_integrations, passed as auto_enabling_integrations.
None follows tracing on SentryConfig, and follows lean error capture on the
Litestar, FastAPI and FastMCP configs, whose framework integrations are
auto-enabling themselves.
Closes#313.
Copy file name to clipboardExpand all lines: docs/introduction/configuration.md
+26Lines changed: 26 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -21,6 +21,7 @@ Additional parameters can also be supplied through the settings object:
21
21
-`sentry_tags` - key/value string pairs that are both indexed and searchable
22
22
-`sentry_additional_params` - additional params, which will be passed to `sentry_sdk.init`, overriding any of the above that map to the same keyword
23
23
-`sentry_default_integrations` - whether to use sentry's default integrations (default: `True`)
24
+
-`sentry_auto_enabling_integrations` - whether sentry-sdk enables an integration for every installed package it knows, such as SQLAlchemy, asyncpg, redis and httpx (default: `None`, meaning off while Sentry tracing is off). See [Sentry auto-enabling integrations](#sentry-auto-enabling-integrations).
24
25
-`sentry_before_send` - optional callback chained after the built-in structlog enricher, passed to `sentry_sdk.init(before_send=...)`
25
26
-`sentry_lean_error_capture` - Litestar, FastAPI and FastMCP: report request errors without sentry-sdk's framework integration (default: `None`, meaning on while Sentry tracing is off). See [Litestar](../integrations/litestar.md#sentry), [FastAPI](../integrations/fastapi.md#sentry) and [FastMCP](../integrations/fastmcp.md#sentry).
26
27
@@ -58,6 +59,31 @@ Two ways to opt out of the appended integration: supply your own `LoggingIntegra
58
59
`sentry_default_integrations=False`, which suppresses it along with every other default integration.
59
60
Under either, `sentry_logging_breadcrumb_level` is ignored and lite-bootstrap warns.
60
61
62
+
### Sentry auto-enabling integrations
63
+
64
+
sentry-sdk enables an integration for every installed package it has one for: the web frameworks,
65
+
SQLAlchemy, asyncpg, redis, httpx, aiohttp, MCP and others. lite-bootstrap passes
66
+
`auto_enabling_integrations` to `sentry_sdk.init`, and `sentry_auto_enabling_integrations` picks it:
67
+
68
+
-`None`, the default: off while Sentry tracing is off, on while it is on. On Litestar, FastAPI and
69
+
FastMCP it follows [`sentry_lean_error_capture`](#sentry) instead: off with lean capture, on when
70
+
sentry-sdk's framework integration reports request errors, because that integration is
71
+
auto-enabling too.
72
+
-`True` or `False`: that value always. An `auto_enabling_integrations` in `sentry_additional_params`
73
+
still wins over both.
74
+
75
+
With tracing off, those integrations still open a span and record a breadcrumb for every SQL
76
+
statement, Redis command or outgoing HTTP request. `SqlalchemyIntegration` measured about 64 µs per
77
+
statement on sentry-sdk 2.70, and `RedisIntegration` +27.1 µs per FastStream publish on 2.73.0 and
78
+
+9.5 µs on 3.0.0b2 ([FastStream](https://github.com/modern-python/lite-bootstrap/blob/main/benchmarks/README.md#8d-faststream)). The default integrations stay:
79
+
dedupe, excepthook, threading, stdlib, atexit, modules, argv and lite-bootstrap's own
80
+
`LoggingIntegration`.
81
+
82
+
Off, error events lose what those integrations add: SQL, Redis and outgoing-HTTP breadcrumbs, and
83
+
anything else an auto-enabled integration attaches. To keep them, set
84
+
`sentry_auto_enabling_integrations=True`, or list just the integrations you want in
85
+
`sentry_integrations`, for example `[SqlalchemyIntegration()]`.
86
+
61
87
### Sentry data collection
62
88
63
89
lite-bootstrap passes an explicit `data_collection` to `sentry_sdk.init`, close to what
Copy file name to clipboardExpand all lines: docs/introduction/performance.md
+6-3Lines changed: 6 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -68,15 +68,18 @@ request, every request then pays the per-record cost measured here:
68
68
69
69
--8<-- "benchmarks/README.md:logging"
70
70
71
-
lite-bootstrap already applies four savings for you. It turns Sentry Logs off in the logging
71
+
lite-bootstrap already applies five savings for you. It turns Sentry Logs off in the logging
72
72
integration, because it never enables them and on 2.x the handler formats every record before
73
73
checking whether they are enabled; that one costs nothing. Since 2.0 it also leaves release-health
74
74
sessions off and starts breadcrumbs at `WARNING`, so an `INFO` record skips the breadcrumb handler.
75
75
Those two cost you release health and `INFO` breadcrumbs on error events; set
76
76
`sentry_auto_session_tracking=True` or `sentry_logging_breadcrumb_level=logging.INFO` to get them
77
77
back. And while Sentry tracing is off it reports request errors without sentry-sdk's framework
78
-
integration, which costs you request transactions and bodies the handler never read; set `sentry_lean_error_capture=False` to keep the integration. The numbers on this page were
79
-
measured before 2.0, against the old defaults.
78
+
integration, which costs you request transactions and bodies the handler never read; set `sentry_lean_error_capture=False` to keep the integration. With tracing off it also turns
0 commit comments