feat: expose the Sentry settings that cost RPS - #231
Merged
Merged
Conversation
lesnik512
force-pushed
the
feat/186-sentry-rps-knobs
branch
from
September 20, 2026 09:45
65559f2 to
78ff6ee
Compare
This was referenced Sep 20, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #186.
Three Sentry settings that measurably cost RPS were reachable only by hand-building
sentry_integrationsor stuffingsentry_additional_params. All three are now config fields.What changed
sentry_logs_level=Noneby default. Unlesssentry_integrationsalready contains aLoggingIntegration,SentryInstrumentappendsLoggingIntegration(level=sentry_logging_breadcrumb_level, sentry_logs_level=None).sentry_auto_session_tracking: bool = True, passed tosentry_sdk.init. Default unchanged.sentry_logging_breadcrumb_level: int | None = logging.INFO, the breadcrumb handler's level.Default unchanged;
Nonedisables breadcrumbs.Why the appended integration is behaviour-preserving
sentry_sdk.integrations.setup_integrationsbuilds{integration.identifier: integration}and onlyfills a default in
if integration_cls.identifier not in integrations, so a user-suppliedLoggingIntegrationstill wins. The appended one differs from sentry-sdk's own default integrationin exactly one handler:
EventHandler(ERROR)andBreadcrumbHandler(INFO)are untouched, onlySentryLogsHandlergoes away.That handler is pure waste here. lite-bootstrap never sets
enable_logs, so Sentry Logs is off, butSentryLogsHandler.emitcallsself.format(record)before it checkshas_logs_enabled(client.options)— filed upstream asgetsentry/sentry-python#7402. Even if that
lands,
sentry_logs_level=Noneremains the correct configuration while the feature is unsupported.When
sentry_default_integrations=Falsethe integration is not appended. Appending it would addan integration the user explicitly disabled, so the opt-out has to win.
sentry_additional_paramsnow overrides instead of collidingAdding
auto_session_trackingas an explicitinitkwarg broke every user who had reached it thedocumented way — the issue itself describes these settings as reachable "by stuffing
sentry_additional_params":bootstrap()now builds aninit_paramsdict thatsentry_additional_paramsupdates, so itoverrides the explicit kwargs for every field rather than colliding with them. Nothing that works
today changes behaviour: a key collision was already a
TypeError.An ignored knob warns
sentry_logging_breadcrumb_levelcannot apply when the user supplies their ownLoggingIntegrationor sets
sentry_default_integrations=False. Rather than fail silently, it goes throughwarn_at_caller, naming which of the two reasons applies — the same shape as"swagger_path differs from docs_url, ... will be used"infastapi_bootstrapper.py. The warningonly fires when the field is off its default, so a user who never touched it never sees it.
Docs and benchmarks
docs/introduction/configuration.mddocuments the three fields, the appended integration and bothopt-outs, linking
benchmarks/README.md§4c for the numbers rather than copying the table.benchmarks/README.mdasserted the opposite of the code in several places, some of it stale sincebefore this branch:
surface for a sampler anywhere in lite-bootstrap". Both OpenTelemetry sampler is not configurable #184 and Pass
exclude_spanstoFastAPIInstrumentorso ASGI send/receive spans are opt-out #185 have since shipped asopentelemetry_samplerandopentelemetry_exclude_spans.LoggingIntegration(level=None, sentry_logs_level=None)andsentry_additional_params={"auto_session_tracking": False}, and carried the OTel knobs as acomment reading "not expressible today". It now uses the real fields throughout. I ran the new
spelling and confirmed it produces an identical client:
_breadcrumb_handler None,_sentry_logs_handler None,_handler EventHandler(ERROR),auto_session_tracking False.Not done, deliberately
sentry_logs_levelconfig field, despite the symmetry with the breadcrumb knob. Anynon-
Nonevalue is pure waste while lite-bootstrap does not support Sentry Logs, so the knob wouldbe generality with no need behind it.
so it fails the "hard to reverse" test.
Testing
Nine new tests in
tests/instruments/test_sentry_instrument.pycovering the disabled logs handler,a user-supplied integration winning,
sentry_default_integrations=False, both knobs reaching theclient,
sentry_additional_paramsoverriding, and the warning firing and staying quiet.307 tests pass;
ruff format,ruff check,tyand a strictmkdocs buildare clean.