DEV Community

Shy Devy
Shy Devy

Posted on

Try Pytheus multiprocess without changing your prometheus code!

There is an extremely experimental feature that allows you to patch in-place the official prometheus_client library.

If you have issues with the official client or just want to try it out it's as simple as:

import prometheus_client
from pytheus.experimental.compatibility import patch_client

patch_client(prometheus_client)
Enter fullscreen mode Exit fullscreen mode

This has to be done at the start/initialization of your application and you can load a different backend before applying with patch with patch_client by using load_backend.

This supports all the metrics types Counter, Gauge, Summary & Histogram. It supports the default REGISTRY and generate_latest. It also works with the start_http_server function.

Of course it's extremely limited and you might be using a feature that is not yet supported, but feel free to try! :)

(This was used to test an internal library without having to migrate all of it, so since I worked on it might as well share it! )

https://github.com/Llandy3d/pytheus

Top comments (0)