Sentry’s Python SDK hit a new major version this week. sentry-sdk 3.0.0 reached PyPI on 23 November 2026, and 3.0.1 followed on 25 November. Version 3 is not a drop-in upgrade. Several options you probably have in sentry_sdk.init() are gone, the logging integration no longer turns on by itself, and the SDK now collects more data by default than 2.x did with send_default_pii off.
This guide covers the changes that affect most apps, with before/after code. All the “after” snippets were run against sentry-sdk==3.0.1 on Python 3.13.
What changed at a glance
According to the official 2.x to 3.x migration guide, the biggest changes are:
- Span streaming is now the only tracing model. Transaction-based tracing is gone.
send_default_piiis replaced by a fine-graineddata_collectionoption.- The
loggingand Loguru integrations are no longer enabled by default. - Most install extras such as
sentry-sdk[fastapi]were removed, since they had no effect.
If you self-host Sentry, the SDK needs self-hosted Sentry 26.4.2 or newer to receive the new span format. Sentry SaaS users don’t need to do anything on the server side.
Step 1: Upgrade in a branch
pip install -U "sentry-sdk>=3.0.1"
If your requirements file says sentry-sdk[django] or sentry-sdk[fastapi], change it to plain sentry-sdk.
Step 2: Fix init() options that no longer exist
Version 3 rejects options it doesn’t know. With 3.0.1, passing send_default_pii=True raises TypeError: Unknown option 'send_default_pii', so your app fails at startup rather than silently ignoring it. That’s good, but it means you have to clean these up before deploying:
| Removed in 3.0 | Use instead |
|---|---|
enable_tracing=True |
traces_sample_rate=... |
enable_logs=True |
Nothing. Sentry logs work without configuration |
send_default_pii, include_local_variables, include_source_context |
data_collection={...} |
propagate_traces |
trace_propagation_targets |
_experiments={"before_send_log": ...} |
Top-level before_send_log=... |
profiles_sample_rate |
profile_session_sample_rate (continuous profiling) |
Before (2.x):
sentry_sdk.init(
dsn=SENTRY_DSN,
enable_tracing=True,
enable_logs=True,
send_default_pii=False,
include_local_variables=False,
_experiments={"before_send_log": drop_debug_logs},
)
After (3.x):
sentry_sdk.init(
dsn=SENTRY_DSN,
traces_sample_rate=0.2,
data_collection={
"stack_frame_variables": False,
"frame_context_lines": 0,
},
before_send_log=drop_debug_logs,
)
Also note that attach_stacktrace now defaults to True, so capture_message() events include a stack trace. Set attach_stacktrace=False if you don’t want that.
Step 3: Decide what data you collect
This is the change to review carefully, especially if you handle personal data. Per the migration guide, the new data_collection defaults are more permissive than send_default_pii=False. Out of the box, 3.x collects user information, HTTP request and response bodies, generative AI inputs and outputs, and more headers and cookies. Values whose keys match a built-in denylist (auth, token, password and similar) are scrubbed. But local variables in stack frames are no longer scrubbed by default.
If you used to rely on send_default_pii being off, switch off the categories you don’t want. Here is a trimmed version of the example in the official guide:
import sentry_sdk
sentry_sdk.init(
dsn=SENTRY_DSN,
data_collection={
"user_info": False,
"http_bodies": [],
"gen_ai": {"inputs": False, "outputs": False},
"database_query_data": False,
"stack_frame_variables": {"mode": "denylist"},
},
)
If you used a custom EventScrubber, it’s gone along with the sentry_sdk.scrubber module. Add your extra sensitive names to the stack-frame denylist instead, and use before_send for any custom scrubbing:
sentry_sdk.init(
dsn=SENTRY_DSN,
data_collection={
"stack_frame_variables": {"mode": "denylist", "terms": ["api_key", "card_number"]},
},
)
The full list of categories is on the Data Collected page.
Step 4: Re-enable logging explicitly
In 2.x, the standard logging integration was on by default, and logger.error(...) created a Sentry issue. In 3.x it’s off by default. Even when you turn it on, it sends log records as Sentry logs and breadcrumbs, not as error events, unless you set event_level.
The option names changed too. level became breadcrumb_level, and sentry_logs_level became level:
import logging
import sentry_sdk
from sentry_sdk.integrations.logging import LoggingIntegration
sentry_sdk.init(
dsn=SENTRY_DSN,
traces_sample_rate=0.2,
integrations=[
LoggingIntegration(
breadcrumb_level=logging.INFO, # breadcrumbs
level=logging.WARNING, # Sentry logs
event_level=logging.ERROR, # error events, like 2.x
),
],
)
If you skip this step, your error dashboards may go quiet after the upgrade. That doesn’t mean your app got better; the logging integration just stopped creating issues. The helper names changed as well: ignore_logger is now ignore_logger_for_events, and ignore_logger_for_sentry_logs is now ignore_logger.
Step 5: Update custom tracing code
If you only use automatic instrumentation from integrations, you probably don’t need to change anything here. If you create spans yourself:
sentry_sdk.start_transaction()andbefore_send_transactionwere removed.- Use
sentry_sdk.start_span(),sentry_sdk.continue_trace(),sentry_sdk.get_current_span()and the@sentry_sdk.tracedecorator. - Spans only carry attributes now. Use
span.set_attribute(key, value)instead ofset_dataor tags. set_measurement()andupdate_current_span()were removed.
with sentry_sdk.start_span(name="nightly-report") as span:
span.set_attribute("report.rows", 1250)
build_report()
Many span operations were renamed to framework-neutral names. For example, Redis spans use db.query instead of db.redis, and Celery and RQ tasks emit queue.publish and queue.process. If your alerts or dashboards filter on old span ops, update them.
Step 6: Replace removed scope APIs
The Hub class, push_scope() and configure_scope() are gone:
# Before
with sentry_sdk.push_scope() as scope:
scope.set_tag("tenant", "acme")
# After
with sentry_sdk.new_scope() as scope:
scope.set_tag("tenant", "acme")
Assigning to scope.user or scope.level directly is no longer supported. Use sentry_sdk.set_user() and sentry_sdk.set_level() instead.
Things that change without code edits
Some behaviour changes only show up in your Sentry UI:
- The SDK no longer sets tags on its own (for example the AWS Lambda
aws_regiontag). Set them yourself if your alerts use them. UnraisableHookIntegrationis now on by default, so errors raised in__del__methods and similar places get reported.DedupeIntegrationnow drops repeat captures of the same exception instance, wherever they come from.- FastAPI and Starlette no longer read the request body eagerly. The body is only attached if your handler already parsed it.
Takeaway
Sentry Python SDK 3.0 removes years of legacy options, but the upgrade needs a short checklist: clean up init(), choose your data_collection settings on purpose, re-add LoggingIntegration with event_level, and move manual spans to the new API. Do it in a branch, trigger a test error, and compare what reaches Sentry before you deploy. The full migration guide in the repository lists every renamed span op and minimum framework version.
