Metrics API returns empty response until TS process serves a prediction
#732 opened on Oct 16, 2020
Repository metrics
- Stars
- (3,844 stars)
- PR merge metrics
- (No merged PRs in 30d)
Description
Context
When the torchserve process initially starts, metrics API endpoints tested return an empty response. While this is a niche case (most likely TS would have served at least 1 prediction before the user calls the metrics APIs), it seems as though the API is broken.
- torchserve version: Installed from source on latest master
- torch version: 1.6.0
- torchvision version 0.7.0
- java version: openjdk-11
- Operating System and version: Ubuntu 18.04
Your Environment
- Installed using source? [yes/no]: Yes
- Are you planning to deploy it using docker container? [yes/no]:N/A
- Is it a CPU or GPU environment?: CPU
- Using a default/custom handler? [If possible upload/share custom handler/model]:No
- What kind of model is it e.g. vision, text, audio?:N/A
- Are you planning to use local models from model-store or public url being used e.g. from S3 bucket etc.? [If public url then provide link.]:N/A
- Provide config.properties, logs [ts.log] and parameters used for model registration/update APIs: Did not use a config.properties (so just the default config)
- Link to your project [if any]:N/A
Expected Behavior
The /metrics endpoint should return the list of metrics whether or not a prediction had been made.
The /metrics?name endpoint should return 0s or display that there were no request logged.
Current Behavior
Both endpoints returns an empty response.
Possible Solution
Steps to Reproduce
How to reproduce:
- Start a new Torchserve process.
- Run
curl http://127.0.0.1:8082/metricsand verify that there is no response. - Make a call to a prediction endpoint. e.g.
curl http://127.0.0.1:8080/predictions/densenet161 -T kitten.jpg - Run
curl http://127.0.0.1:8082/metricsagain and verify the expected response is returned (the list of metrics).
Same behavior for curl "http://127.0.0.1:8082/metrics?name[]=ts_inference_latency_microseconds&name[]=ts_queue_latency_microseconds" --globoff
Failure Logs [if any]
Note that the metrics API doesn't return results until the first prediction is served. metrics_api_success.txt