Skip to content

feat(sentry)!: support sentry-sdk 3 alongside 2.x and raise the floor to 2.70 - #359

Merged
lesnik512 merged 2 commits into
mainfrom
feat/306-sentry-sdk-3
Oct 28, 2026
Merged

lesnik512 merged 2 commits into
mainfrom
feat/306-sentry-sdk-3

Conversation

@lesnik512

@lesnik512 lesnik512 commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Closes #306.

lite-bootstrap now runs on sentry-sdk 2.70 and later, on both majors. The sentry extra changes from three marker-split >=2.1/2.11/2.59,!=2.69.0,<3 lines to sentry-sdk>=2.70,<4.

Changes

  • LoggingIntegration per major. IS_SENTRY_SDK_2 replaces the inspect.signature probe. 2.x gets level=breadcrumb_level, sentry_logs_level=None, as before. 3.x gets breadcrumb_level=breadcrumb_level, event_level=logging.ERROR, level=None, because on 3.x level means Sentry Logs and event_level defaults to None. The two dicts are one conditional expression, so line coverage reaches 100% on either major.
  • Explicit data_collection. DEFAULT_DATA_COLLECTION is the migration guide's dict for matching send_default_pii=False, plus "stack_frame_variables": {"mode": "denylist"}. It is passed on both majors. A user's own data_collection in sentry_additional_params still replaces it.
  • Removed 2.1-era shims. The enricher reads and writes only logentry["formatted"], which 2.70 and 3.x both fill.
  • CI. A new sentry-majors job runs the full suite on sentry-sdk<3 and on sentry-sdk==3.0.0b2. The pytest jobs keep resolving the newest stable release, so after GA they test 3.x, and this job still covers 2.x. Replace the 3.0.0b2 pin with the GA release once it ships.
  • Docs. configuration.md covers the integration on both majors, and a new "Sentry data collection" section says what is collected. It also says that 3.0 raises TypeError for removed options passed through sentry_additional_params.

Departures from the issue

  • The issue was written against 3.0.0b1. I tested on 3.0.0b2, released 2026-10-27. b2 kept trace_lifecycle, and it removed options the issue doesn't list (enable_metrics, stream_gen_ai_spans, trace_ignore_status_codes). The docs therefore name a few removed options and link the migration guide instead of copying a list that is still changing.
  • No separate "3.x installs a logging integration" test. The rewritten test (an INFO and an ERROR log produce exactly one envelope item, an event) fails if the integration is missing, and the existing sentry_default_integrations=False test runs on both majors in the new job.
  • The two formatted/message parametrized tests are deleted entirely. With the message case gone, test_drops_event_on_skip_sentry_before_message_check and test_modify_lifts_message_and_attaches_extra already cover what was left.

Tests

Written first, against main's code:

  • test_sentry_bootstrap_turns_error_logs_into_events_and_sends_no_sentry_logs: on 3.0.0b2 it got a log item and no event.
  • test_sentry_filters_secret_stack_frame_variables: failed on both majors. On 2.73, the default EventScrubber matches exact key names, so a local named api_token reached Sentry in clear. On 3.0, locals aren't scrubbed at all. The data_collection denylist matches substrings, so it catches both.
  • test_sentry_collects_no_user_info_or_http_bodies_by_default: failed on both majors, because 2.73 resolves http_bodies to all body types when data_collection isn't passed.
  • test_sentry_additional_params_data_collection_replaces_the_default

Main's suite on 3.0.0b2 had 6 failures. This branch passes all 454 tests at 100% coverage on 2.70.0, 2.73.0 and 3.0.0b2. just lint, just adr-check, just docs-build and lychee pass.

Breaking changes

  • The sentry-sdk floor is now 2.70 (released 2026-09-22).
  • On 2.x, the EventScrubber no longer runs, because sentry-sdk skips it whenever data_collection is set. Filtering now comes from data_collection: denylist matching on headers, cookies, query parameters and frame variables.
  • send_default_pii=True in sentry_additional_params has no effect on 2.x, because data_collection wins. On 3.x it raises TypeError. To collect more, pass data_collection instead, for example {**DEFAULT_DATA_COLLECTION, "user_info": True}.

Benchmarks

benchmarks/ used 2.x-only APIs, so after GA the lint job would have failed there. The second commit makes the scripts type-check and run on both majors.

  • The shared scenarios build LoggingIntegration per major.
  • On 3.x a request with tracing off gets a NoOpSpan, so the per-request Transaction cost that ASGI integrations build and discard a Transaction per request when tracing is disabled (~34 µs) getsentry/sentry-python#7400 measures doesn't exist there. The parts that probe that cost stay 2.x-only:
    • the *_skip_txn and errors_only_lazy_sample_rand patches
    • errors_only_txn_endpoint_style, because 3.x has no transaction_style
    • repro_sentry_txn.py --patched, which exits with a message on 3.x
  • On 3.x, micro.py times continue_trace and the root start_span instead.
  • 2.x-only names are reached through Any-typed handles (importlib.import_module, setattr), so ty passes against either major.
  • The README still reports its 2.67.1 measurements, and now says what differs on 3.x.

ty check passes against 2.73.0 and 3.0.0b2. On both majors I ran run.py (sentry and stack suites), verify.py, micro.py, repro_sentry_txn.py and profile_one.py with small request counts, checking only that they run. I didn't run run_http.py, which needs ab. Its only Sentry dependency is the scenario names it validates, and those are the same ones run.py exercised.

@lesnik512 lesnik512 added this to the 2.0.0 milestone Oct 28, 2026
@lesnik512
lesnik512 merged commit 03a20c0 into main Oct 28, 2026
37 checks passed
@lesnik512
lesnik512 deleted the feat/306-sentry-sdk-3 branch October 28, 2026 16:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support sentry-sdk 3.0 alongside 2.x

1 participant