Skip to content

polish: TeardownError aggregation, cascade tests, README lifecycle#111

Merged
lesnik512 merged 3 commits into
mainfrom
polish/teardown-aggregation-cascade-readme
Jun 5, 2026
Merged

polish: TeardownError aggregation, cascade tests, README lifecycle#111
lesnik512 merged 3 commits into
mainfrom
polish/teardown-aggregation-cascade-readme

Conversation

@lesnik512

Copy link
Copy Markdown
Member

Summary

Closes the three non-blocking follow-ups flagged during PR1/PR2 final reviews. All small, all earned by the 2026-06-05 audit cycle, none blocking.

  • fix: Generalize TeardownError aggregation across instruments. PR1's final reviewer noted that only LoggingInstrument.teardown() aggregated failures into TeardownError; the other instruments raised on first failure and skipped later cleanup steps. Now uniform:
    • OpenTelemetryInstrument.teardown() — each uninstrument() call is wrapped in its own try/except; tracer provider shutdown() is also protected; failures aggregate into a single TeardownError(errors) raised at the end. Logger restoration always runs even if an instrumentor raised.
    • FastStreamLoggingInstrument.teardown() — wraps the broker params_storage write in try/finally so super().teardown() always runs.
    • SentryInstrument.teardown() — wraps sentry_sdk.flush(timeout=2) in try/finally so sentry_sdk.init() (the SDK reset) always runs.
  • test: Parametrize the OTel-insecure-endpoint cascade test across all framework configs. PR2's final reviewer noted the __post_init__ super() cascade was tested only through FastAPIConfig. The new test covers FreeConfig, LitestarConfig, FastStreamConfig, and FastAPIConfig (redundant safety net) so future inheritance refactors can't silently drop the cascade for any config.
  • docs: Add a "Lifecycle constraints" section to README.md. Four constraints earned by the audit cycle that aren't obvious from the API: one bootstrapper per application instance, one OpenTelemetryInstrument per process, idempotent teardown(), and TeardownError aggregation on partial failures.

Test plan

  • just test — 194 passed (187 baseline + 3 instrument-agg tests + 4 cascade-parametrize cases), 100% coverage.
  • just lint-ci — clean (ruff, eof-fixer, ty).
  • Each commit scoped to one logical change.

Audit cycle status

This wraps up the 2026-06-05 bug-audit-v2 work. The audit closed 26 findings across PR1 (#108), PR2 (#109), and PR3 (#110). The retrospective (planning/specs/2026-06-05-bug-audit-v2-retro.md) flagged three deferred items as non-blocking follow-ups — all three land here.

🤖 Generated with Claude Code

lesnik512 and others added 3 commits June 5, 2026 21:26
PR1's final reviewer flagged that only LoggingInstrument used TeardownError
aggregation; other instruments raised on first failure and skipped subsequent
cleanup. Generalize the pattern: OpenTelemetryInstrument.teardown aggregates
instrumentor uninstrument errors and tracer provider shutdown errors;
FastStreamLoggingInstrument wraps the broker write in try/finally so
super().teardown() always runs; SentryInstrument wraps flush in try/finally
so init() always runs to disable the SDK.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
…configs

PR2's final reviewer noted the __post_init__ super() cascade was tested only
through FastAPIConfig. Add a parametrized test covering FreeConfig,
LitestarConfig, FastStreamConfig, and FastAPIConfig (redundant safety net)
so future MRO refactors can't silently break the cascade for any config.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Four constraints earned by the 2026-06-05 audit cycle that aren't obvious
from the API: one-bootstrapper-per-application-instance,
one-OpenTelemetryInstrument-per-process, teardown idempotency,
and TeardownError aggregation on partial failures.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@codecov

codecov Bot commented Jun 5, 2026

Copy link
Copy Markdown

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 Δ
...bootstrap/bootstrappers/faststream_bootstrapper.py 100.00% <100.00%> (ø)
..._bootstrap/instruments/opentelemetry_instrument.py 100.00% <100.00%> (ø)
lite_bootstrap/instruments/sentry_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_opentelemetry_instrument.py 100.00% <100.00%> (ø)
tests/instruments/test_sentry_instrument.py 100.00% <100.00%> (ø)
tests/test_config.py 100.00% <100.00%> (ø)
tests/test_faststream_bootstrap.py 100.00% <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 Jun 5, 2026
@lesnik512 lesnik512 merged commit be1e498 into main Jun 5, 2026
9 checks passed
@lesnik512 lesnik512 deleted the polish/teardown-aggregation-cascade-readme branch June 5, 2026 18:36
lesnik512 added a commit that referenced this pull request Jun 5, 2026
Bug-audit-v2 cycle: 26 findings across 4 PRs (#108-#111). Lifecycle hardening,
config validation, CI gate, generalized TeardownError aggregation. Two
behavior changes called out: FastAPIConfig no longer stomps user app fields;
CorsConfig wildcard+credentials now raises.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
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