-
Notifications
You must be signed in to change notification settings - Fork 368
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
Improve exception logging #1992
Conversation
This allows us to distinguish which product is originating the failed requests, e.g.: ``` ERROR -- ddtrace: [ddtrace] (.../client.rb:38:in `rescue in send_request') Internal error during Datadog::Profiling::Transport::HTTP::Client request. ``` for profiling.
Ruby exceptions can have really confusing, vague, or even empty messages. To help us out during debugging, I've added the exception class in exception-related logs to give us more context while debugging issues. This is quite low-hanging fruit, but I think in general we have a long way to go in improving exception logging in dd-trace-rb. In particular, we should probably look into centralizing exception logging in a method to solve the following: * Eliminate duplication. Can you spot how often I had to copy paste `e.class.name` in this PR? * There's a few cases where we just log the message, without any context. (I did not touch those) * The formatting of our error messages is quite inconsistent. Sometimes we include the backtrace, sometimes not. Sometimes we call the backtrace location, sometimes source, etc. * Sometimes we call the logger with a block (so that the string does not need to be generated if logging is disabled at that level), sometimes we just pass in a string. * There is no way to get the full stack trace, if we need to know more about where an error came from. But... for now here's a smaller improvement.
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 like this, any improvement, however small, is welcome.
Cool! I'll hold off on pressing the magic button so we can finish putting 1.0.0 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.
Does it make sense to extract some part of this error message formatting to a Utils
function? Not a huge deal, but may be useful to get consistent behavior/formatting in the printed message.
It does, a lot! But improving this is a bit of a rabbit hole, so I decided to take a small step, and leave further improvements for the future :) |
Ruby exceptions can have really confusing, vague, or even empty messages.
To help us out during debugging, I've added the exception class in exception-related logs to give us more context while debugging issues.
This is quite low-hanging fruit, but I think in general we have a long way to go in improving exception logging in dd-trace-rb.
In particular, we should probably look into centralizing exception logging in a method to solve the following:
Eliminate duplication. Can you spot how often I had to copy paste
e.class.name
in this PR?There's a few cases where we just log the message, without any context. (I did not touch those)
The formatting of our error messages is quite inconsistent. Sometimes we include the backtrace, sometimes not. Sometimes we call the backtrace location, sometimes source, etc.
Sometimes we call the logger with a block (so that the string does not need to be generated if logging is disabled at that level), sometimes we just pass in a string.
There is no way to get the full stack trace, if we need to know more about where an error came from.
But... for now here's a smaller improvement.