Skip to content

Keep FastStream observability alive through complete shutdown - #443

Open
lesnik512 wants to merge 1 commit into
mainfrom
fix/faststream-shutdown-lifecycle
Open

lesnik512 wants to merge 1 commit into
mainfrom
fix/faststream-shutdown-lifecycle

Conversation

@lesnik512

Copy link
Copy Markdown
Member

FastStream previously tore down observability in on_shutdown, before broker drain and user lifespan cleanup. Wrap the lifespan so teardown runs after both, including when startup or shutdown raises. Keep automatic cleanup after direct stop() and application context-manager usage when no enclosing lifespan owns teardown.

Preserve the original lifecycle error when teardown also fails, attaching cleanup details as exception notes. Forward lifespan arguments unchanged and document the ordering change in the integration and 2.x migration guides.

Validation:

  • Failing ASGI regression originally exported only the during-service span; broker-drain and user-shutdown spans now export too.
  • Public lifecycle tests cover startup/shutdown failures, exporter shutdown failures, argument forwarding, and cleanup exactly once. Failing-first regressions preserve direct start/stop and application context-manager cleanup.
  • FastStream 0.7.8: all 69 tests in the FastStream test file pass.
  • FastStream 0.6.0: 19 new lifecycle cases pass; the application context-manager case is skipped because that API is absent. Running the full FastStream file also exposes eight existing multi-broker tests requiring the newer add_broker API.
  • Full suite: 662 passed, 100% coverage.
  • Ruff lint, tracked-file formatting, EOF checks, type checking, and strict documentation build passed.
  • Standards and spec reviews: no remaining findings.

Closes #434.

This branch has not been deployed

No deployments
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.

[P2] Keep FastStream observability alive through complete shutdown

1 participant