starlette_exporter icon indicating copy to clipboard operation
starlette_exporter copied to clipboard

Need requests_inprogress metric as a default metric

Open scotgopal opened this issue 3 years ago • 2 comments

This is one of the basic metrics when it comes to monitoring requests made to a server. Such a metric is useful to give additional insight on the kind of load that the server is going through in that particular moment.

This is the feature that I plan to work on for this package.

scotgopal avatar Jun 30 '21 21:06 scotgopal

the requests_in_progress metric is now available in v0.10.0! Thanks @scotgopal for contributing it.

Since you requested paths in the metric, we can leave this issue open until we are also tracking the request path.

stephenhillier avatar Jul 14 '21 04:07 stephenhillier

the requests_in_progress metric is now available in v0.10.0! Thanks @scotgopal for contributing it.

Since you requested paths in the metric, we can leave this issue open until we are also tracking the request path.

Duly noted. Thank you @stephenhillier . Hope we can work together in future contributions too.

scotgopal avatar Jul 14 '21 04:07 scotgopal

I am going to close this as done, since in-progress requests metrics are working but I still haven't come up with a way to automatically label it by path.

If anybody needs in-progress requests counts by path, my suggestion for now is to just add an extra Gauge to the function you are interested in (example borrowed from https://github.com/prometheus/client_python#gauge):

from prometheus_client import Gauge

g = Gauge('my_inprogress_requests', 'Description of gauge')

async def some_view(request):
    with g.track_inprogress():
        pass

stephenhillier avatar Aug 14 '22 04:08 stephenhillier