Closed andykent closed 4 years ago
👍 👍 👍
A similar crash #40 has occurred.
@andykent thank you for this awesome work and sorry for taking so long to review. This is a crucial PR for LoggerJSON. I left a couple of comments on how we can make it better and then LGTM. ❤️
Thanks for taking the time to review @AndrewDryga ❤️
I think I addressed both your points. The only bit I am still unsure about is the handling of Keyword lists.
The PR currently converts Keyword lists to Maps but I'm not 100% convinced that this is the best option...
Pros: Means that Keyword lists show up nicely in Google Logging UI and can be used to search and set metrics on. e.g. data.kw_list.key="value"
Cons: Semantics are different so order is not preserved and duplicate keys are dropped. Might be confusing as datatype is different in logs from code. We have to attempt to process things that look like keyword lists and bail with rescue
when they are not.
The options...
inspect
on them - clearest in logs but loses all searching/metrics semantics.data.kw_list[0].key="value" || data.kw_list[1].key="value"
feels kind of horrid.I don't honestly have a strong opinion here as none are ideal so it's probably just a case of choosing the least bad option. Unless anyone has any other recommendations for how to handle this?
Thanks again for the review, excited to see this merged soon so we can get off of our fork.
@andykent I think being able to pass KV lists and filter by them in logging aggregator is a good reason to drop duplicate keys. This is all about metadata sent by the application so if a developer needs to have them in another form, it's easy to structure metadata differently in that specific place.
@AndrewDryga Yep, agreed, this is the original reason I went this route. OK, think the PR is good then. Will be testing it out in production this week and can report back.
@andykent this is awesome that you can test if first, tell me if everything is good and I'll merge this PR and release a new version. Thank you again ❤️
This PR adds a new
JasonSafeFormatter
module which is able to recursively walk metadata and make coerce it into Jason.encode! safe.I can confirm that this fixes #40 as we have experienced this in production and a few other Logger crashes related to dodgy data ending up in metadata.
We have made some opinionated calls on how to format the data when not compatible but hopefully this is an improvement on the current situation.
The opinionated bits are likely...
Credit where credit is due, I used a few commits from this coingaming fork for some pointers when putting this together.