Closed justinreddick closed 1 year ago
The request_in_progress
is likely to always be 1 if you run the demo script as the script is the only client accessing routes that trigger metrics updates and it is only perfroming one request at a time. This is due to the simplicity of the example script. You can see from the request_total
metric that the route had been accessed 338 times, so the script was working.
If you wanted to increase the likelihood of seeing multiple requests being in-progress you could modify the script to perform two fetches. Something like this:
async def handle_requests():
# Start up the server to expose the metrics.
await svr.start(port=8000)
# Generate some requests.
while True:
# Perform two requests to increase likelihood of observing two
# requests in progress when fetching metrics.
await asyncio.gather(
handle_request(random.random()),
handle_request(random.random()),
)
If I run the curl command repeatedly to fetch metrics I occasionally see 2 requests in progress, like this:
(aioprom) $ curl http://127.0.0.1:8000/metrics
# HELP request_in_progress Number of requests in progress
# TYPE request_in_progress gauge
request_in_progress{route="/"} 2
# HELP request_total Total number of requests
# TYPE request_total counter
request_total{route="/"} 30
Greetings,
I copied and ran the
@inprogress
decorator example, and when viewing the metrics endpoint, I observed the metric did not increment. It stayed at 1Using python 3.9.11, using this requirements.in: