Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions gen3workflow/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ async def get_status():
app.include_router(s3_router, tags=["S3"])
app.include_router(storage_router, tags=["Storage"])
app.include_router(system_router, tags=["System"])
app.include_router(s3_root_router, tags=["S3"])

# Following will update logger level, propagate, and handlers
get_logger("gen3workflow", log_level=log_level)
Expand Down Expand Up @@ -99,6 +98,8 @@ async def get_status():
if app.metrics.enabled:
app.mount("/metrics", app.metrics.get_asgi_app())

app.include_router(s3_root_router, tags=["S3"])
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nss10 When you have a chance could you add a comment explaining why it's not done at the same time as the other routers 🙏


@app.middleware("http")
async def middleware_log_response_and_api_metric(
request: Request, call_next
Expand All @@ -121,7 +122,7 @@ async def middleware_log_response_and_api_metric(

# NOTE: If adding more endpoints to metrics, try making it configurable using a list of paths and methods in config.
# For now, we are only interested in the "/ga4gh/tes/v1/tasks" endpoint for metrics.
if method != "POST" or path != "/ga4gh/tes/v1/tasks":
if method != "POST" or path.rstrip("/") != "/ga4gh/tes/v1/tasks":
return response

metrics = app.metrics
Expand Down
6 changes: 6 additions & 0 deletions gen3workflow/routes/system.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from fastapi import APIRouter, HTTPException, Request
from fastapi.responses import RedirectResponse
from starlette.status import HTTP_500_INTERNAL_SERVER_ERROR

from gen3workflow import logger
Expand All @@ -24,3 +25,8 @@ async def get_status(request: Request) -> dict:
except Exception:
raise HTTPException(HTTP_500_INTERNAL_SERVER_ERROR, "Unable to reach TES API")
return dict(status="OK")


@router.get("/metrics", include_in_schema=False)
async def redirect_metrics():
return RedirectResponse(url="/metrics/")
Loading
Loading