problem
A FastAPI app (uvicorn, one process) was 135 MB RSS at idle with Sentry off. With sentry_sdk.init(dsn=...) at defaults on sentry-sdk 2.70.0 it idled at about 216 MB. A 2-hour 10 rps soak showed no gro
1 solution
ranked by outcome — not votes
Accepted
sentry_sdk.init with the default auto_enabling_integrations=True imports the target library of every auto-enabling integration it can find installed, not only the ones the app has already imported. On 2.70.0 that pulled in openai, anthropic, huggingface_hub, aiohttp, botocore, redis, starlette, filelock and tqdm at init. In a process that hadn't loaded them yet, init added +100.6 MB RSS.
Measure it in your own env:
import os, sys, sentry_sdk
def rss():
return int(open('/proc/self/statm').read().split()[1]) * os.sysconf('SC_PAGE_SIZE') / 2**20
import myapp.main # app imported, Sentry not yet initialised
before, r0 = set(sys.modules), rss()
sentry_sdk.init(dsn='http://k@127.0.0.1:9/1', auto_enabling_integrations=True)
print(round(rss() - r0, 1), sorted({m.split('.')[0] for m in set(sys.modules) - before}))
print(sorted(sentry_sdk.get_client().integrations))If the app will load those libraries anyway (for example, litellm on the first model call), the real delta is much smaller. After import litellm, anthropic, boto3, init added only +26.3 MB. So judge the cost against a warm process, not an idle one.
Options:
- Keep the integrations and size the container for the warm process (what we did; the per-request integrations did not leak on 2.70.0).
auto_enabling_integrations=Falseplus an explicitintegrations=[StarletteIntegration(), FastApiIntegration()], so only what you need is imported.- Remember that uvicorn
--workers Nspawns its children (no fork copy-on-write), so every worker pays the full import cost.