[V1][Metrics][Plugin] Add plugin support for custom StatLoggerBase implementations (#22456)
Signed-off-by: tovam <tovam@pliops.com>
This commit is contained in:
@@ -12,6 +12,7 @@ from prometheus_client import Counter, Gauge, Histogram
|
||||
from vllm.config import SupportsMetricsInfo, VllmConfig
|
||||
from vllm.distributed.kv_transfer.kv_connector.v1.metrics import KVConnectorLogging
|
||||
from vllm.logger import init_logger
|
||||
from vllm.plugins import load_plugins_by_group
|
||||
from vllm.v1.engine import FinishReason
|
||||
from vllm.v1.metrics.prometheus import unregister_vllm_metrics
|
||||
from vllm.v1.metrics.stats import (
|
||||
@@ -56,6 +57,23 @@ class StatLoggerBase(ABC):
|
||||
pass
|
||||
|
||||
|
||||
def load_stat_logger_plugin_factories() -> list[StatLoggerFactory]:
|
||||
factories: list[StatLoggerFactory] = []
|
||||
|
||||
for name, plugin_class in load_plugins_by_group("vllm.stat_logger_plugins").items():
|
||||
if not isinstance(plugin_class, type) or not issubclass(
|
||||
plugin_class, StatLoggerBase
|
||||
):
|
||||
raise TypeError(
|
||||
f"Stat logger plugin {name!r} must be a subclass of "
|
||||
f"StatLoggerBase (got {plugin_class!r})."
|
||||
)
|
||||
|
||||
factories.append(plugin_class)
|
||||
|
||||
return factories
|
||||
|
||||
|
||||
class AggregateStatLoggerBase(StatLoggerBase):
|
||||
"""Abstract base class for loggers that
|
||||
aggregate across multiple DP engines."""
|
||||
|
||||
Reference in New Issue
Block a user