prometheus / client_python

Prometheus instrumentation library for Python applications
Apache License 2.0
3.97k stars 797 forks source link

Would it be nice to document `Registry`, `Collector` and metric classes? #803

Open liuzheng1990 opened 2 years ago

liuzheng1990 commented 2 years ago

Hi guys. Thanks for providing this great library for making monitoring fun and easy in python. It's my Day 1 with this package. The README provided a very quick introduction but I was also puzzled at the following question:

  1. Seems we defined some metric classes, but not assigned to any other things. The web server was started but it seemed magical that the server somehow knows the metric class objects.

This puzzle was gone after I checked out the source codes (which is very fun to read, thanks!) and realized that there's a global REGISTRY object. The server app takes a registry object which is by default the global REGISTRY, and each Collector object, in the __init__ method, also accepts a registry object, which by default is also REGISTRY.

I think it would be nice if there could be some API reference sections/pages. I'd be glad to contribute such a section, but would like to hear any comment from the community, like the necessity, proposed format, etc.

Cheers!

csmarchbanks commented 2 years ago

:+1: So far all of our documentation is in the readme, and I think at least a small section describing what a registry is would be good to have there. We just start using a registry in examples right now without any indication as to what it is.