prometheus / prometheus/client_python
ASGI lifespan crash
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
client_python version: testing on 0.15.0 but the offending code exists in the master branch as well.
I'm trying to use the prometheus ASGI handler with Hypercorns DispatcherMiddleware. It sends lifecycle events which are not properly handled:
def make_asgi_app(registry: CollectorRegistry = REGISTRY, disable_compression: bool = False) -> Callable:
"""Create a ASGI app which serves the metrics from a registry."""
async def prometheus_app(scope, receive, send):
assert scope.get("type") == "http"
# Prepare parameters
assert scope.get("type") == "http" ensures any ASGI middleware sending lifecycle events will fail to start the prometheus asgi app.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at the make_asgi_app function and its assertion that the ASGI scope type is http. Reproduce the failure using the Prometheus ASGI handler with Hypercorn's DispatcherMiddleware, including its lifecycle events. Done means lifecycle events no longer crash startup while the handler still serves metrics requests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100