[V1][Metrics][Frontend] Add support for custom stat loggers via CLI --stat-loggers #21105
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
✨ Add Support for Custom Stat Logger Classes via CLI Argument
This PR adds support for dynamically loading custom
StatLoggerBaseclasses via a new command-line argument:--stat-loggers.The purpose is to allow injection of user-defined metric loggers into the vLLM runtime without modifying internal code.
🔧 What’s New
Added a new CLI argument:
--stat-loggers: comma-separated list of fully-qualified class paths(e.g.,
mylogger.PrometheusLogger,mylogger.JsonLogger)These classes are dynamically imported using
importlib, and passed toAsyncLLM.from_vllm_config.📍 Example Usage
💬 Context & Motivation
This PR builds on the work in #14661, which enabled
AsyncLLMto accept customStatLoggerBaseinstances directly.It takes the next step by introducing a CLI-level hook for dynamically loading loggers.
This enables plug-and-play observability setups, supports multiple concurrent loggers, and follows a clean, extensible pattern that avoids hardcoding.