Skip to content

Commit

Permalink
[Bugfix] Fix 307 Redirect for /metrics (#4523)
Browse files Browse the repository at this point in the history
  • Loading branch information
robertgshaw2-redhat authored May 1, 2024
1 parent a88bb9b commit 4dc8026
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion vllm/engine/metrics.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ def __init__(self, labelnames: List[str], max_model_len: int):
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])

Expand Down
8 changes: 6 additions & 2 deletions vllm/entrypoints/openai/api_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
import importlib
import inspect
import os
import re
from contextlib import asynccontextmanager
from http import HTTPStatus

Expand All @@ -12,6 +13,7 @@
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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4dc8026

Please sign in to comment.