Merged
Conversation
0c8cda2 to
b216da4
Compare
c1526a4 to
d9049ca
Compare
b59071e to
12f322a
Compare
Closes #513 - Add pgqueuer.metrics.prometheus module with collect_metrics function - Use QueriesProtocol for flexible integration with any queries implementation - Update documentation with FastAPI, Flask, and Starlette examples - Add tests for metrics formatting and framework integrations
- Add pgqueuer.metrics.fastapi with create_metrics_router - Add pgqueuer.metrics.flask with create_metrics_blueprint - Add optional dependencies: pgqueuer[fastapi], pgqueuer[flask] - Update documentation with simplified examples - Add tests for framework integrations
- Remove factory pattern in favor of direct Queries injection - Simpler API: just pass your Queries instance - Update docs and tests accordingly
- Delete pgqueuer/metrics/flask.py - Remove flask from optional and dev dependencies in pyproject.toml - Remove Flask integration section from prometheus-metrics-service.md - Remove Flask-related tests from test_metrics_prometheus.py - Regenerate uv.lock
- Remove QueriesProtocol, use Queries directly - Remove add_prefix from prometheus_format (metric names are already configurable via MetricNames)
12f322a to
108e6ca
Compare
Align metrics collection with ports-and-adapters architecture by depending on the QueueRepositoryPort protocol instead of the concrete Queries class. This enables metrics to work with any repository implementation and improves testability through dependency injection. - Add log_statistics method to QueueRepositoryPort - Update prometheus.py and fastapi.py to accept QueueRepositoryPort - Update tests to use the protocol abstraction - Remove unused ReduceFn type alias
Rename test variables to avoid type annotation conflicts and mark QueueRepositoryPort as @runtime_checkable for proper protocol handling. - Rename repository variables to fake_repo in tests for clarity - Add @runtime_checkable to QueueRepositoryPort - Add minimal type: ignore[arg-type] annotations where needed
Use explicit typing.cast() instead of type: ignore comments to handle structural subtyping of FakeQueries to QueueRepositoryPort. This is more semantically correct and avoids suppressing type errors. - Replace 4 'type: ignore[arg-type]' with cast() calls - Remove unnecessary @runtime_checkable decorator - Improve code clarity with explicit intent
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 #513
pgqueuer.metrics.prometheusmodule withcollect_metricsfunctionpgqueuer.metrics.fastapimodule withcreate_metrics_routerfor plug-and-play FastAPI integrationfastapioptional dependency (pip install pgqueuer[fastapi])Summary
Framework-agnostic Prometheus metrics integration for PGQueuer. The core
collect_metricsfunction returns a Prometheus-formatted string that can be served from any web framework. A plug-and-play FastAPI router is provided for convenience.Testing
make checkpassedChecklist