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 4e4e02e
Browse filesBrowse the repository at this point in the historyBrowse files
Report FastAPI and FastMCP errors without StarletteIntegration while tracing is off (#362)
* Report FastAPI and FastMCP errors without StarletteIntegration while tracing is off
While Sentry tracing is off, FastAPIBootstrapper and FastMcpBootstrapper disable
sentry-sdk's StarletteIntegration (and FastApiIntegration on FastAPI) and report
request errors through a pure-ASGI middleware instead, with the same
sentry_lean_error_capture rule Litestar got in #361. The rule now lives in
SentryLeanCaptureConfig, shared by all three configs.
Closes#341.
* Stop the integration reset fixture from re-patching Starlette in every test
Clearing sentry-sdk's processed-integrations registry before each test made
StarletteIntegration.setup_once run again for every bootstrap, and each run
wraps Starlette.__call__ once more. By the end of the suite 126 wrappers were
stacked, enough to overflow the stack on Python 3.11 in CI. Once an
integration has been set up, the fixture now replaces its setup_once with a
no-op, so the registries still read as a fresh process without patching twice.
* Keep the exploding test handler from failing a later test's logging shutdown
test_teardown_removes_filters_even_when_a_handler_close_fails added a handler
whose close always raised and left it on the root logger. Its exception kept
it alive until the cyclic garbage collector ran, so whether Litestar's
dictConfig in a later test closed it again, and failed, depended on GC timing.
The handler now raises on its first close only, and the test detaches it.
Copy file name to clipboardExpand all lines: docs/introduction/configuration.md
+4-3Lines changed: 4 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,12 +22,13 @@ Additional parameters can also be supplied through the settings object:
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
24
-`sentry_before_send` - optional callback chained after the built-in structlog enricher, passed to `sentry_sdk.init(before_send=...)`
25
-
-`sentry_lean_error_capture` - Litestar only: report request errors without Sentry's `LitestarIntegration`(default: `None`, meaning on while Sentry tracing is off). See [Litestar](../integrations/litestar.md#sentry).
25
+
-`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
26
27
27
Read more about sentry_sdk params [here](https://docs.sentry.io/platforms/python/configuration/options/).
28
28
29
-
Sentry is the second most expensive instrument in the stack. Its cost comes almost entirely from the ASGI
30
-
integration; see [Performance](performance.md).
29
+
Before 2.0, Sentry was the second most expensive instrument in the stack, and its cost came almost
30
+
entirely from sentry-sdk's framework integration. Since 2.0, lite-bootstrap replaces that integration on
31
+
Litestar, FastAPI and FastMCP while Sentry tracing is off; see [Performance](performance.md).
@@ -65,13 +68,15 @@ request, every request then pays the per-record cost measured here:
65
68
66
69
--8<-- "benchmarks/README.md:logging"
67
70
68
-
lite-bootstrap already applies three savings for you. It turns Sentry Logs off in the logging
71
+
lite-bootstrap already applies four savings for you. It turns Sentry Logs off in the logging
69
72
integration, because it never enables them and on 2.x the handler formats every record before
70
73
checking whether they are enabled; that one costs nothing. Since 2.0 it also leaves release-health
71
74
sessions off and starts breadcrumbs at `WARNING`, so an `INFO` record skips the breadcrumb handler.
72
75
Those two cost you release health and `INFO` breadcrumbs on error events; set
73
76
`sentry_auto_session_tracking=True` or `sentry_logging_breadcrumb_level=logging.INFO` to get them
74
-
back. The numbers on this page were measured before 2.0, against the old defaults.
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.
75
80
76
81
## What each saving costs you
77
82
@@ -92,7 +97,8 @@ The same instruments one at a time, in-process, in the Linux container:
92
97
--8<-- "benchmarks/README.md:fastapilinux"
93
98
94
99
The ordering matches macOS: OpenTelemetry first, then Sentry, then Prometheus, with logging free
95
-
until something logs.
100
+
until something logs. Since 2.0, Sentry with tracing off drops from about +59 to about +6 µs per
0 commit comments