uvicorn icon indicating copy to clipboard operation
uvicorn copied to clipboard

Access logs for mounted apps doesnt not contain the root path

Open euri10 opened this issue 3 years ago • 3 comments

This change broke our monitoring a bit. We use FastAPI and mount a ASGI-app to /graphql route. Since access logs are not really useful for GraphQL we filter them out in our monitoring to avoid a lot of noise. Since this change access logs are logging / instead of /graphql which breaks this and makes our logs very noisy again.

Originally posted by @levrik in https://github.com/encode/uvicorn/issues/1294#issuecomment-1046761532

euri10 avatar Feb 21 '22 13:02 euri10

thanks for that @levrik

we should maybe use raw_path instead of path in

def get_path_with_query_string(scope: WWWScope) -> str:
    path_with_query_string = urllib.parse.quote(scope["path"])

euri10 avatar Feb 21 '22 13:02 euri10

Thanks a lot for transitioning this into an issue. I'll give your suggestion a try and open a PR.

levrik avatar Feb 21 '22 15:02 levrik

I've opened a PR (#1385) which switches to raw_path in logging. We've tested this with our application which successfully brought the log filtering back to life.

levrik avatar Feb 22 '22 11:02 levrik

Same issue as https://github.com/pgjones/hypercorn/issues/75.

This is an issue on Starlette's side: https://github.com/encode/starlette/issues/1336.

Kludex avatar Sep 11 '22 13:09 Kludex