chore: add debug logging and recovery to agent api requests #20785
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I am trying to debug coder/internal#1010 and coder/internal#1059 where I get a context timeout on API requests to the agent.
So, I thought maybe it could make sense to log agent API requests to see if it is even getting the requests, along with adding the recovery middleware because maybe it is panicking.
Because rbac cannot be imported in slim, I had to split the logger middleware into slim and non-slim versions.
And similarly, exclude other middleware that will not make sense in a slim context (mostly because they import rbac or database).
Although, I wonder if I should just break out the middleware I need (
recover,loggermw, andtracingright now) into a new package because most ofhttpmwseems to be designed around being used in coderd specifically and will probably never make sense in a slim context. Would a top-levelhttpmwpackage make sense maybe?@Emyrk tagged you just because I saw a comment elsewhere about possibly creating a new package for middleware