Conversation
bentsku
left a comment
There was a problem hiding this comment.
This is really awesome! I can really see us making use of this to debug.
I've had to wrangle with the handler chain before, and I remember setting print statement in each handler where I thought the issue was. I know, I could have also used the debugger, but I had to read a stream and I didn't know where it was consumed and was trying to consume it manually .The debugger didn't like showing the stream either (I think there's some issue there with pyCharm). Anyway, this is sidetracking, but it's exactly why this would be really useful.
Tracking each handler individually is really nice, that be for performance, consuming a stream, or any other issue we can encounter. So, thanks a lot for adding this functionality, I can see myself using it in the weeks coming.
Actually, I can see us using it pretty soon: we have an issue in CI where the body of an S3 pre-signed URL is consumed, but only in CI. We could set up a branch with a circleCI job with this feature enabled, running on some selected failing tests and see what exactly is happening. This is really awesome, I can't say it enough.
So, yeah, L(Super)GTM.
This PR targets localstack developers and adds tracing functionality to debug the handler chain.
I think this can be useful for work that involves a lot of debugging in the HTTP framework (thinking APIGW, S3, CORS, Lambda, issues with request streaming, ...) 👀 @bentsku @alexrashed @calvernaz @dfangl @dominikschubert
You can enable this behavior by setting
DEBUG_HANDLER_CHAIN=1By wrapping handlers and recording before/after state of the context, request, and response object, we can report in quite a detailed way what the handler did to the request/response.
This includes
I'm sure there are better/more generic ways of implementing it than the way I did, but I feel for a first iteration it's OK.
Here are some examples of how the report looks like. I know they're not super pretty - happy for suggestions.
calling a non-implemented operation:
calling
awslocal opensearch list-domain-namescalling the health endpoint