From ba752b2140e4af3c66c465520cc88019c129067b Mon Sep 17 00:00:00 2001 From: Masahiro Masuda Date: Fri, 1 Dec 2023 10:56:07 +0000 Subject: [PATCH] minor --- serve/mlc_serve/api/handler.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/serve/mlc_serve/api/handler.py b/serve/mlc_serve/api/handler.py index da26871b7d..8457502c38 100644 --- a/serve/mlc_serve/api/handler.py +++ b/serve/mlc_serve/api/handler.py @@ -65,18 +65,19 @@ def _get_sampling_params(request: ChatCompletionRequest) -> SamplingParams: @router.get("/metrics") def metrics(): + # See https://prometheus.github.io/client_python/multiprocess/ for why we need this. if "PROMETHEUS_MULTIPROC_DIR" in os.environ: from prometheus_client import ( CollectorRegistry, generate_latest, multiprocess, ) + from starlette.responses import Response + registry = CollectorRegistry() multiprocess.MultiProcessCollector(registry) - from starlette.responses import Response - resp = Response(content=generate_latest(registry)) - return resp + return Response(content=generate_latest(registry)) else: return {}