prometheus / prometheus/client_python
Provide APIs to help application developers test their Histogram-using code
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
I have an application that uses Histogram. I want to write some tests that assert that my application is putting values into the right buckets of that histogram.
To read values out of the Histogram it seems that need to either:
- look at the Histogram's private
_bucketsattribute, or - call
Histogram.collectand look at the resultingMetricobjects which are documented as "intended only for internal use" and then look at itsSampleswhich aren't documented at all.
Neither of these seems particularly satisfactory. It would be very helpful if client_python provided some way to read bucket counts and the total sum from a Histogram, using documented APIs clearly marked as intended for external use (perhaps only in test suites).
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 inspecting the Python client’s Histogram implementation, especially its _buckets attribute and collect method, along with the Metric and Samples objects it returns. Define and test a documented external API for reading bucket counts and the total sum, with coverage showing that application tests can assert values without using private or internal-only objects.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100