Files
wehub-resource-sync 770d92cb1f
Lint / lint (push) Has been cancelled
Build Docs / Deploy Docs (push) Has been cancelled
Windows CI / Windows (push) Has been cancelled
chore: import upstream snapshot with attribution
2026-07-13 13:23:58 +08:00

24 lines
878 B
Python

"""MLC LLM server metrics entrypoints"""
import fastapi
from fastapi.responses import PlainTextResponse
from mlc_llm.serve.server import ServerContext
app = fastapi.APIRouter()
################ /metrics ################
@app.get("/metrics", response_class=PlainTextResponse)
async def metrics(_request: fastapi.Request):
"""Start the cuda profiler for the engine. Only for debug purpose."""
server_context: ServerContext = ServerContext.current()
# Use the metrics from first engine for now
# TODO(mlc-team): consider refactor server context to
# single engine since multiple AsyncMLCEngine do not work well with each other
# We need to work within the internal engine instead.
for model in server_context.get_model_list():
async_engine = server_context.get_engine(model)
return (await async_engine.metrics()).prometheus_text()