Skip to content

feat(sentry)!: leave release-health sessions off and start log breadcrumbs at WARNING - #360

Merged
lesnik512 merged 1 commit into
mainfrom
feat/310-340-sentry-defaults
Oct 28, 2026
Merged

lesnik512 merged 1 commit into
mainfrom
feat/310-340-sentry-defaults

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Closes #310. Closes #340.

This PR changes two Sentry defaults that cost time on every request or log record:

field was now
sentry_auto_session_tracking True False
sentry_logging_breadcrumb_level logging.INFO logging.WARNING

_warn_breadcrumb_level_ignored used to compare against logging.INFO to tell whether the user had changed the field. It now compares against logging.WARNING, so an explicit INFO is treated as a change from the default. When sentry_integrations brings its own LoggingIntegration, or sentry_default_integrations=False is set, that explicit INFO is ignored and lite-bootstrap warns.

Tests

Written first, all failing on main:

  • test_sentry_does_not_track_sessions_by_default: the client's auto_session_tracking option is False.
  • test_sentry_breadcrumbs_start_at_warning_by_default: the breadcrumb handler's level is WARNING.
  • test_sentry_error_event_carries_no_info_breadcrumbs_by_default: an INFO and a WARNING record logged before an error leave only the WARNING breadcrumb on the event. The test uses its own logger and filters by category, because the event also carries a subprocess breadcrumb from sentry-sdk working out the release.
  • test_sentry_warns_when_a_non_default_info_breadcrumb_level_is_ignored: on main, INFO was the default, so no warning was raised.

test_sentry_logging_breadcrumb_level_controls_the_breadcrumb_handler gains a WARNING case. The full suite passes at 100% coverage on sentry-sdk 2.73.0 and 3.0.0b2, and ty passes against both. just lint, just adr-check, just docs-build and lychee pass.

Measurement

#340 asks for a rerun showing that an INFO call at WARNING costs about what it costs at None. Each mode ran in its own process: one structlog log.info call through FreeBootstrapper, output to /dev/null, median of 5 × 20000 calls, measured in-process on an M2 Mac.

sentry-sdk no Sentry breadcrumbs at INFO at WARNING None
2.73.0 10.04 µs 15.35 µs 10.26 µs 10.29 µs
3.0.0b2 9.55 µs 15.75 µs 10.56 µs 10.50 µs

The new default saves about 5 µs per INFO record on both majors. I didn't rerun the session cost for #310. The 7.7 µs per request in the docs and the 7.2 to 8.7 µs re-measured in #310 both come from the issue, and the default change affects nothing else.

Docs

  • configuration.md: the two bullets give the new defaults and say how to get the old behaviour back. The paragraph saying breadcrumbs "stay on by default" is rewritten.
  • performance.md:
    • The session row is marked as the default since 2.0.
    • The "applies one saving for you" paragraph now lists all three savings, along with what the two new ones cost you.
    • It says the page's numbers were measured against the pre-2.0 defaults.
  • benchmarks/README.md:
    • The tuned snippet, which performance.md includes, drops sentry_auto_session_tracking=False because that is now the default.
    • A line under the snippet records that the tuned runs set it explicitly.
  • sentry_scenarios.py: the errors_only comment says it reproduces 1.x's defaults. Its kwargs are unchanged, so the numbers measured with it are still valid.

Breaking changes

  • Release health: crash-free session and user rates stop. Set sentry_auto_session_tracking=True to keep them. Only the HTTP frameworks opened sessions per request, so FastStream and Free behave the same as before.
  • Breadcrumbs: error events no longer carry INFO log breadcrumbs. Set sentry_logging_breadcrumb_level=logging.INFO to keep them.

@lesnik512 lesnik512 added this to the 2.0.0 milestone Oct 28, 2026
@lesnik512
lesnik512 merged commit 06c3ec1 into main Oct 28, 2026
37 checks passed
@lesnik512
lesnik512 deleted the feat/310-340-sentry-defaults branch October 28, 2026 16:54
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.

Default sentry_logging_breadcrumb_level to logging.WARNING Default sentry_auto_session_tracking to False

1 participant