Skip to content

Commit 7a2d9eb

Browse files
committed
fix missing metrics endpoint
see vllm-project/vllm#6463
1 parent 0b69d69 commit 7a2d9eb

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

src/vllm_tgis_adapter/__main__.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@
7575

7676
router = APIRouter()
7777

78-
# Add prometheus asgi middleware to route /metrics requests
79-
route = Mount("/metrics", make_asgi_app())
80-
# Workaround for 307 Redirect for /metrics
81-
route.path_regex = re.compile("^/metrics(?P<path>.*)$")
82-
router.routes.append(route)
78+
79+
def mount_metrics(app: fastapi.FastAPI) -> None:
80+
# Add prometheus asgi middleware to route /metrics requests
81+
metrics_route = Mount("/metrics", make_asgi_app())
82+
# Workaround for 307 Redirect for /metrics
83+
metrics_route.path_regex = re.compile("^/metrics(?P<path>.*)$")
84+
app.routes.append(metrics_route)
8385

8486

8587
@router.get("/health")
@@ -188,6 +190,8 @@ async def _force_log(): # noqa: ANN202
188190
app.include_router(router)
189191
app.root_path = args.root_path
190192

193+
mount_metrics(app)
194+
191195
app.add_middleware(
192196
CORSMiddleware,
193197
allow_origins=args.allowed_origins,

0 commit comments

Comments
 (0)