-
Notifications
You must be signed in to change notification settings - Fork 51
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add structured logging #88
Conversation
- JSON output - tests for all levels
- Rename `logger` to `structured_logger` to avoid confusion with the `Logger` delivery option - CLI: Interrupt/Terminal signal received - Connection: Started, processing, idling, set mailbox, start TLS, logged in, disconnected - Mailbox: Delivery arbitrator - Delivery options (postback/que/sidekiq): Message delivered - Watcher: setup
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good direction, my main comment is that I'd input hashes only when using structured logging. That allows for better indexing. Thanks for iterating on my work! 💯
Basically the same comments with @ZJvandeWeg 😄 |
Thanks @engwan and @ZJvandeWeg ! I'll get those pushed up. Great feedback! |
fd5711e
to
915ca22
Compare
- Standardise structured log inputs for action, context, delivery_option, byte size, uid...
915ca22
to
249ceab
Compare
@cablett Thank you for this PR! I'd like to step back a bit, and understand: what is problem you're trying to solve? |
Have you looked at existing structured logging options? |
I think it's twofold:
Either gem look like they would do the job, and their JSON formatters look similar to what is proposed here. However, this is a pretty lightweight implementation, and the other options require a bit more configuration and add another dependency. Would you prefer to use one of those gems? |
Thank you @stanhu. So, this is a bit complex, and unfortunately @cablett, you've kind of stumbled into something that has been on my mind for months, if not years. In summary, I want to get this right. The way I've been thinking about it for quite some time (and obviously, never gotten around to implementing) is two-fold:
So, to handle these I imagine there are 3 things I'd like to do:
And, just to make it more challenging: So … all that said, I'm happy to review the details of, and merge, this PR. But, I will likely be requesting changes in service of future work. I will, however, try to begin this work very soon (hopefully this coming weekend). OR, if you're okay with it, I can carry this information into an issue, and start a design proposal to gather feedback; and close this PR. |
As far as dependencies go, I'm not terribly worried about it, beyond looking at the dependencies of In the case of https://github.com/tilfin/ougai they depend on some sort of JSON encoder/decoder and use https://github.com/rocketjob/semantic_logger requires |
@stanhu if you have time, I'd love to hear more examples of this kind. What I have so far; we want stats/info for:
|
Thank you so much for this @tpitale ! It really helps at the moment to have a glimpse into the information that mail_room can provide, because it's rather opaque at the moment. If this solution is at least acceptable (though perhaps not the ideal), it would still be an improvement. I suppose what I'm saying is that I'd like to get this merged, as it would satisfy a pain point at present. If you do decide to merge, we can continue to discuss how to iterate on it, which may involve tearing out this logging at a later date (if turns out to be a local maxima), or making it one of several configurable options, etc. Thanks for the shoutout to |
@cablett Great, I'll do a quick review of this, and you can maybe rebase on master as there will be a few CI fixes that should help with the Travis failures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think this looks great. Only really two requests:
- try to switch to a non-global logger to a per-mailbox (or disabled) logger config
- have a no-cost disabled logger option
Thanks @cablett!
Many thanks @tpitale ! I'll do my best to get those done today. Thank you again for your work on this ✨ |
0590c46
to
35f2989
Compare
All looking better now, thanks for those requirements. I think it might be ready now. Would you please have another look? (I realised I resolved some discussions but you might not consider them resolved - please feel free to un-resolve if you have further comments) ✨ |
- Initial filename configurable in yml file - No filename entry means no structured logging (current behaviour) - Remove singleton structured logger in favour of per-mailbox logfiles
35f2989
to
273ba3e
Compare
- Add missing `name` param to mailbox constructor options
The only unresolved thought I have remaining about this is that I had to take out the line in the |
- Add missing `name` param to mailbox constructor options
- Remove residual old test
data.to_json + "\n" | ||
end | ||
|
||
def noop? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where does this get called?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, looking at the internals of Logger
, if @logdev
is nil, it is a noop already. We don't need to add any special code.
Sorry for making you do that. This can come out.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I'll merge this, and then I can just remove this in another commit.
Thank you @cablett! 💛💙❤️ |
Yes, that's probably the bulk of it for now. We actually also care about unread count sampled throughout the day, just in case we need to alert on the inbox growing without bound for some reason. |
I added a structured logger based on @ZJvandeWeg 's earlier PR.
I called it
structured_logger
but I'm happy to call it something else if you feel that's a bit unwieldy.Thank you for all your work on this gem @tpitale !