Skip to content

Conversation

@rolodato
Copy link
Contributor

@rolodato rolodato commented Apr 2, 2025

Example log entries running with LOGGING='{"log_level":"DEBUG","log_format":"json"}':

{"method": "POST", "url": "/api/v1/identities/", "client_host": "127.0.0.1", "logger": "edge_proxy.middleware", "level": "debug", "timestamp": "2025-04-02T22:32:21.128069Z", "message": "request"}
{"method": "POST", "url": "/api/v1/identities/", "status_code": 200, "size": 2356, "duration_ms": 14, "logger": "edge_proxy.middleware", "level": "debug", "timestamp": "2025-04-02T22:32:21.141611Z", "message": "response"}

@matthewelwell
Copy link
Contributor

@rolodato rather than adding a custom middleware, I'd rather rely on uvicorn's access logs. It looks like there's some customisation needed in order to log out the timestamp, but I think that's better than a middleware. Is there a reason that you went with a middleware here instead?

@rolodato
Copy link
Contributor Author

rolodato commented Apr 3, 2025

The access log prints one log entry per completed request, for example:

2025-04-03T12:22:48.139024Z [info     ] 127.0.0.1:54940 - "POST /api/v1/identities/ HTTP/1.1" 200 [uvicorn.access] method=POST path=/api/v1/identities/ remote_ip=127.0.0.1:54940 status=200

The difference with the middleware is that, if a request is never responded, then the access log will not print anything. The middleware would print a log for the request, but not for the response. You can simulate this by adding an infinite loop to any Edge Proxy endpoint.

I haven't found a way to get uvicorn to log requests and responses separately. We'll wait to hear back from the customer that requested this enhancement to see if the access logs would be enough to troubleshoot their issue.

@rolodato
Copy link
Contributor Author

rolodato commented Apr 7, 2025

Closing this PR until we confirm it's necessary.

@rolodato rolodato closed this Apr 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants