Skip to content

Commit

Permalink
fix missing metrics endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
dtrifiro committed Jul 19, 2024
1 parent 0b69d69 commit 7a2d9eb
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions src/vllm_tgis_adapter/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,13 @@

router = APIRouter()

# Add prometheus asgi middleware to route /metrics requests
route = Mount("/metrics", make_asgi_app())
# Workaround for 307 Redirect for /metrics
route.path_regex = re.compile("^/metrics(?P<path>.*)$")
router.routes.append(route)

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


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

mount_metrics(app)

app.add_middleware(
CORSMiddleware,
allow_origins=args.allowed_origins,
Expand Down

0 comments on commit 7a2d9eb

Please sign in to comment.