Skip to content

fix: strip skip_sentry from Sentry context; drop dead is_X_installed conjuncts#92

Merged
lesnik512 merged 1 commit into
mainfrom
fix/des-4-5-small-cleanups
May 31, 2026
Merged

fix: strip skip_sentry from Sentry context; drop dead is_X_installed conjuncts#92
lesnik512 merged 1 commit into
mainfrom
fix/des-4-5-small-cleanups

Conversation

@lesnik512
Copy link
Copy Markdown
Member

@lesnik512 lesnik512 commented May 31, 2026

Summary

Two small audit cleanups bundled:

  • DES-4 (Sentry): skip_sentry was already triggering event suppression when truthy, but for falsy values (False/missing/"") the flag itself wasn't stripped from the structlog payload and ended up as noise in event["contexts"]["structlog"]. Add "skip_sentry" to IGNORED_STRUCTLOG_ATTRIBUTES. Regression added as a parametrize case on the existing test_modify.
  • DES-5 (dead conjuncts): Four instruments' is_ready() methods ended with and import_checker.is_X_installed. That conjunct is provably unreachable — BaseBootstrapper._register_or_skip calls check_dependencies() first and only invokes is_ready() if it returned True. Behavior is unchanged; cleanup makes the lifecycle easier to reason about.

Closes DES-4 and DES-5 from an internal audit.

Test plan

  • just test -- tests/instruments/test_sentry_instrument.py -v — all parametrize cases pass.
  • just test — full suite 84/84.
  • just lint — clean (no F401 unused-import warnings; import_checker still used by check_dependencies() in every instrument).
  • Reviewer: confirm the DES-5 invariant by reading lite_bootstrap/bootstrappers/base.py:44-64is_ready() is only invoked on an instrument that already passed check_dependencies().

Notes for reviewer

  • import_checker import statement remains in all four instrument files (still referenced by each check_dependencies() method).
  • Code review surfaced one nice-to-have follow-up: adding a skip_sentry: true parametrize case to test_modify for unit-level coverage of the suppression path (the integration test test_sentry_instrument_with_structlog_error already covers it). Out of scope for this PR.

🤖 Generated with Claude Code

…conjuncts

DES-4: enrich_sentry_event_from_structlog_log was already returning None
(suppressing the event) when skip_sentry was truthy, but for falsy values
(False, missing, "") the flag itself was not stripped from the structlog
payload before it was attached to event["contexts"]["structlog"]. Add
"skip_sentry" to IGNORED_STRUCTLOG_ATTRIBUTES so the field never leaks
into Sentry context noise. Regression test added as a parametrize case
on the existing test_modify.

DES-5: each affected instrument's is_ready() returned `<config check> and
import_checker.is_X_installed`. The conjunct is provably dead: BaseBootstrapper
calls check_dependencies() in _register_or_skip before instantiating the
instrument, and only invokes is_ready() if check_dependencies() returned True.
Drop the redundant conjunct from SentryInstrument, LoggingInstrument,
OpenTelemetryInstrument, and PyroscopeInstrument. Behavior is unchanged.

Closes DES-4 and DES-5 from the audit.
@codecov
Copy link
Copy Markdown

codecov Bot commented May 31, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Flag Coverage Δ
unittests 100.00% <100.00%> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
lite_bootstrap/instruments/logging_instrument.py 100.00% <100.00%> (ø)
..._bootstrap/instruments/opentelemetry_instrument.py 100.00% <100.00%> (ø)
lite_bootstrap/instruments/pyroscope_instrument.py 100.00% <100.00%> (ø)
lite_bootstrap/instruments/sentry_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_sentry_instrument.py 100.00% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@lesnik512 lesnik512 self-assigned this May 31, 2026
@lesnik512 lesnik512 merged commit 78f8a62 into main May 31, 2026
8 checks passed
@lesnik512 lesnik512 deleted the fix/des-4-5-small-cleanups branch May 31, 2026 21:19
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.

1 participant