-
Notifications
You must be signed in to change notification settings - Fork 55
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
Include params and arity in formatted backtrace #115
Include params and arity in formatted backtrace #115
Conversation
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.
This looks great 👍
| api_key | Your application's Honeybadger API key | System.get_env("HONEYBADGER_API_KEY"))` | | ||
| environment_name | (required) The name of the environment your app is running in. | nil | | ||
| app | Name of your app's OTP Application as an atom | Mix.Project.config[:app] | | ||
| use_logger | Enable the Honeybadger Logger for handling errors outside of web requests | true | |
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 you accidentally removed app
and use_logger
documentation
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.
You're correct, I did! I've restored it.
lib/honeybadger/backtrace.ex
Outdated
defp format_args(args, false = _filter) when is_list(args) do | ||
Enum.map(args, &inspect/1) | ||
end | ||
defp format_args(_arity, _filter) do |
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.
Can we rename this to _args
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.
When it isn't a list it is a number, which really is the arity of the function. Stack traces are guaranteed to have either the args or arity, so this is indicating what the argument really is.
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.
My bad :) I thought the first argument would always be a list. I thought, this head was to match when filter was true. 👍
mix.exs
Outdated
@@ -36,6 +36,7 @@ defmodule Honeybadger.Mixfile do | |||
notice_filter: Honeybadger.NoticeFilter.Default, | |||
filter: Honeybadger.Filter.Default, | |||
filter_keys: [:password, :credit_card], | |||
filter_args: false, |
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.
If this is an opt-in feature, we should default to filter_args: true
. @joshuap thoughts?
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'm thinking we want to disable this feature by default. We discussed making it opt-in in #78 (comment). Does that make sense, @sorentwo?
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've reversed the default, it is now true
, making it opt-in like we discussed 👍
I think we do want to do something to handle super large structures. In our ruby gem we truncate the maximum string size that can be sent as any value to 64KiB. That's more of a catch-all which applies to any data (including context). We also apply some extra sanitization to |
This enhances the backtrace to include function arity and arguments, if available. The arguments are inspected to ensure they can be serialized as JSON without any issues.
@joshuap I've started on a spike to implement customized Going with |
@sorentwo Is there anything pending on this PR? Are you planning on pushing a new commit with the review suggestion changes? |
Yes, there is work pending and a commit that I haven’t pushed. I’ve been on vacation for the past week, this will be a little while longer. |
To prevent serializing entire structs or lengthy binaries we now pass opts to `Kernel.inspect/2` when generating a backtrace.
@minhajuddin @joshuap The changes to inspected arguments have been pushed up. We're using I've set the list/tuple/struct limit to 5 elements, and the printed limit to 1024 bytes. Those felt like reasonable amounts, let me know what you think. The values are all configured in a module attribute at the top of |
Looks great 👍 |
Is anything blocking this still? I'd love to get it merged, it would be helpful with a few errors I'm seeing currently. |
@sorentwo we still need to implement on the backend, sorry for the delay. I'll look into that next. |
@sorentwo I'm trying to test this out in my Phoenix app. I'm getting the function arity, but I'm still getting empty args when I set the config
|
@joshuap According to this post on erlang questions by Lukas Larsson (@garazdawi) the only time it will ever give arguments instead of arity is:
I've been experimenting with causing various errors and checking the stacktrace, I only seem to be able to get the arity. I'm not sure what else to do here, I'll try looking at how elixir/iex manages to display arguments and clauses so thoroughly. |
Very relevant to this discussion, and the future handling of stacktraces: elixir-lang/elixir#7097 |
I created issue #123 to track improvements to argument handling. In any case, Honeybadger now supports displaying arguments with the stack trace, so I'm going to merge this! Edit: Here's a screenshot of a stack trace w/ arity: https://screenshots.firefox.com/QvQDSbBPKao2c0qG/app.honeybadger.io |
This enhances the backtrace to include function arity and arguments, if available. The arguments are inspected to ensure they can be serialized as JSON without any issues.
Argument inclusion is configured with
filter_args
, which defaults tofalse
. Therefore by default arguments are included in a notice's backtrace. When arguments are filtered an empty list will be returned instead.Also note, Poison can't encode tuples, structs, pids, refs, etc. so
inspect
is called on each argument. It may be preferable to be more selective with argument formatting, as a struct or list may be quite large. Any thoughts on this?Addresses #78