[Bugfix] Fix 307 Redirect for /metrics (#4523)

This commit is contained in:
Robert Shaw 2024-05-01 12:14:13 -04:00 committed by GitHub
parent a88bb9b032
commit 4dc8026d86
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 7 additions and 3 deletions

View File

@ -119,7 +119,7 @@ class Metrics:
buckets=[1, 2, 5, 10, 20],
)
self.counter_request_success = Counter(
name="vllm:request_success",
name="vllm:request_success_total",
documentation="Count of successfully processed requests.",
labelnames=labelnames + [Metrics.labelname_finish_reason])

View File

@ -2,6 +2,7 @@ import asyncio
import importlib
import inspect
import os
import re
from contextlib import asynccontextmanager
from http import HTTPStatus
@ -12,6 +13,7 @@ from fastapi.exceptions import RequestValidationError
from fastapi.middleware.cors import CORSMiddleware
from fastapi.responses import JSONResponse, Response, StreamingResponse
from prometheus_client import make_asgi_app
from starlette.routing import Mount
import vllm
from vllm.engine.arg_utils import AsyncEngineArgs
@ -55,8 +57,10 @@ def parse_args():
# Add prometheus asgi middleware to route /metrics requests
metrics_app = make_asgi_app()
app.mount("/metrics", metrics_app)
route = Mount("/metrics", make_asgi_app())
# Workaround for 307 Redirect for /metrics
route.path_regex = re.compile('^/metrics(?P<path>.*)$')
app.routes.append(route)
@app.exception_handler(RequestValidationError)