Closed remstone7 closed 1 year ago
We have a local variables feature in our Ruby gem—I'm wondering if this would be similar to that? These are the important parts:
https://github.com/honeybadger-io/honeybadger-ruby/blob/dd52c352567026b891484b4a1c62fa6e739cbd1f/lib/honeybadger/notice.rb#L228 https://github.com/honeybadger-io/honeybadger-ruby/blob/dd52c352567026b891484b4a1c62fa6e739cbd1f/lib/honeybadger/notice.rb#L228 https://github.com/honeybadger-io/honeybadger-ruby/blob/master/lib/honeybadger/plugins/local_variables.rb
cc @subzero10 @Kelvin4664
Not sure if this is also related to #90 at all.
@joshuap yea it looks similar to what i'm asking for here, do the local variables get added to the context or is there another part in the UI that they get added to?
@joshuap yea it looks similar to what i'm asking for here, do the local variables get added to the context or is there another part in the UI that they get added to?
They would get added to the backtrace—not the context, assuming the info is available from Python. This may still be a slightly different feature from what you're asking for, but I'm not sure. I think #90 is more like if the backtrace shows the method foo()
was called with two args, it would include the values, i.e. foo('value one', 'value two')
. It would do that for every line of the backtrace that includes a method call.
The local variable feature in Ruby displays the local variables only for the first line of the application trace, and it includes regular variable assignments, i.e.:
def my_method
foo = "foo value"
bar = "bar value"
# `foo` and `bar` will be included in local variables
raise "error here"
end
It does not include them in context, but I think the UI is similar (it may actually display them inline w/ the first line of the backtrace).
@joshuap i'll make a pr, but to confirm, local_variables will just be for the block that the exception is raised?
For 1 function
def run():
count=0
try:
a['a']
except Exception as e:
honeybadger.notify(e)
for a multiple-caller:
def runner(x, y):
test_data = {"foo": "bar"}
try:
y / x
except Exception as e:
honeybadger.notify(e)
def caller():
runner(0, 3)
caller()
@joshuap i'll make a pr, but to confirm, local_variables will just be for the block that the exception is raised?
For 1 function
def run(): count=0 try: a['a'] except Exception as e: honeybadger.notify(e)
for a multiple-caller:
def runner(x, y): test_data = {"foo": "bar"} try: y / x except Exception as e: honeybadger.notify(e) def caller(): runner(0, 3) caller()
Yeah, that seems right. Thanks, we'll review the PR soon!
@remstone7 You can try your changes with v0.13.0
! Thank you for submitting the PR!
@subzero10 thank you, working on my end 👍
It looks like this isn't a possibility yet but it would be great to be able to have local variables present in the stack trace. As far as I can tell, the only way you can do this in the current system would be to use context.
the
inspect
packagetrace
allows you to get thef_locals
and this could be added to the context of a project.