Currently, vllm.py and sglang.py both use regex to search for different metric values. This is both unsafe and unreadable. We should use the prometheus_client in python instead. It contains a parser specifically designed to parse the Prometheus text exposition format into structured Python objects. Instead of using raw regex, we can use prometheus_client.parser.text_string_to_metric_families. Haven't implemented this yet as I cannot test it right now but will when I can.
Currently,
vllm.pyandsglang.pyboth use regex to search for different metric values. This is both unsafe and unreadable. We should use theprometheus_clientin python instead. It contains a parser specifically designed to parse the Prometheus text exposition format into structured Python objects. Instead of using raw regex, we can useprometheus_client.parser.text_string_to_metric_families. Haven't implemented this yet as I cannot test it right now but will when I can.