prometheus / prometheus/client_python
OpenMetrics support for textfile collector
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.4k
- Forks
- 876
- Avg merge
- 8d 4h
- Merged PRs (30d)
- 1
Description
Currently prometheus_client.exposition.write_to_textfile doesn't support the OpenMetrics text format, which I'm addressing with this (private) hack:
from prometheus_client.openmetrics.exposition import (
generate_latest as generate_latest_openmetrics,
)
from prometheus_client.registry import CollectorRegistry
def write_openmetrics_to_textfile(path: str, registry: CollectorRegistry) -> None:
"""
Fork of `prometheus_client.exposition.write_to_textfile`, as the project
didn't provide an OpenMetrics variant of this helper function.
"""
with open(path, "wb") as fp:
fp.write(generate_latest_openmetrics(registry))
Would your project be interested in a non-hacky (as is the case above) OpenMetrics support for textfile collector?
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 prometheus_client.exposition.write_to_textfile and compare its behavior with prometheus_client.openmetrics.exposition.generate_latest. Determine how the helper should expose OpenMetrics output while preserving the existing textfile collector behavior. Done means the supported helper writes valid OpenMetrics text for the provided registry and is covered by the project's relevant tests.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- observability
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100