claws / aioprometheus

A Prometheus Python client library for asyncio-based applications
175 stars 21 forks source link

ProcessCollector support #36

Open easysugar opened 4 years ago

easysugar commented 4 years ago

Hi. It would be nice to have something like ProcessCollector. Using ProcessCollector from prometheus_client raises an error:

Traceback (most recent call last):
  File "prom.py", line 5, in <module>
    prometheus_service.register(ProcessCollector(namespace='mydaemon'))
  File "/usr/local/lib/python3.7/site-packages/aioprometheus/service.py", line 177, in register
    self.registry.register(collector)
  File "/usr/local/lib/python3.7/site-packages/aioprometheus/registry.py", line 32, in register
    raise TypeError("Invalid collector type: {}".format(collector))
TypeError: Invalid collector type: <prometheus_client.process_collector.ProcessCollector object at 0x7f2887ca0c10>

Code:

from prometheus_client import ProcessCollector
from aioprometheus import Service

prometheus_service = Service()
prometheus_service.register(ProcessCollector(namespace='mydaemon'))