Add JSON log output support via logrus #249
Open
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.
First pass at adding JSON log output support + traceable transaction IDs (in the form of a UUID-based
X-Request-ID
) that allows you to tie most log lines to a given request.This gets a little messy because there is no central log context. Logrus has an example of setting a program-wide field to include, but it doesn't work with something that changes so often (like a transaction ID that changes on every received request). Notably missing here is lack of support for including the transaction ID in log lines from the S3 and GCS cache implementations because I didn't have a way to pass the transaction ID and didn't want to use a global var.
This was really a proof of concept for our own internal usage since we front ImageProxy with nginx for better visibility into how long ImageProxy requests are taking. With these changes, we'll have a way to link nginx logs (we use the standard ECS format) with ImageProxy logs via the transaction ID.
I'd love some feedback here -- whether that's telling me that I'm doing this all wrong and need to start over, or that I should keep this in my own fork, either is okay 😂
(purposely left tests broken)
Before:
After: