Closed
Description
Hi! I've recently created a few libraries that are helpful for extracting information from frames and tracebacks, and I think they could be very useful to sentry.
executing
can identify the exact AST node being executed by a frame in many cases. It's always disappointed me that Python only points to a line in each frame in tracebacks, especially when the expression/statement at fault spans many lines. Sometimes it can be really hard to interpret. Currently executing is used in IPython (in master, unreleased) to highlight the node, here's what it looks like:
executing
can also infer a function__qualname__
from a code object, meaning your traceback can saylorem/ipsum.py in MyClass.__init__ at line 123
instead of just__init__
, which is much more informative.pure_eval
can safely evaluate certain AST nodes without side effects, so that if the source for a frame contains expressions likeself.foo
andbar[key]
their values can often be shown alongside plain variables.stack_data
collects data from tracebacks for the purpose of formatting and displaying them. It usesexecuting
andpure_eval
and also provides a lot of functionality of its own. For example, in this frame:
there are lines from complex_filter
which the user doesn't need to see, and stack_data
knows how to filter those out by only collecting lines which belong in the current scope. I integratedstack_data
into IPython which allowed removing a lot of flaky custom introspection code, fixing several bugs and making the code more maintainable.
stack_data
identifies the locations of variables and evaluated expressions in the source lines. An intelligent UI could use this, for example, to allow the user to hover over a variable in source code to see its value rather than scroll through a list to find it.
Overall there are lots of possibilities. What would interest you? I'm willing to make a PR and make any necessary changes to the libraries.
Metadata
Metadata
Assignees
Labels
No labels