prometheus / prometheus/client_python
Async context manager
Open
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
Usecase:
c = Counter("errors_count")
@c.count_exceptions()
def foo(): # counter = 1
raise Exception()
@c.count_exceptions()
async def foo_async(): # counter still 1
await sleep(1)
raise Exception()
Quick search in project did nothing to me.
It would be cool if counter (and other objects) would handle this right out of the box, especially if we're talking about metrics for web world.
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 by tracing the Counter implementation and its count_exceptions() decorator, then inspect how the example behaves for foo_async. Define the supported async context-manager or decorator behavior and verify that exceptions from the async example update the counter as requested.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability-sre
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100