newrelic-python-agent
newrelic-python-agent copied to clipboard
Support for Chained Exception Tracebacks
Is your feature request related to a problem? Please describe.
Being able to see the tracebacks for chained exceptions as a part of the stack trace in the NewRelic Errors UI is helpful for debugging issues in our code.
Currently, only the traceback for the most recent exception is considered when building error nodes. The traceback is extracted from sys.exc_info() in _observe_exception(...), then formatted by this call to exception_stack(...).
Feature Description
Ideally, exception_stack(...) should take in the value of the exception, then read and format the traceback from its __traceback__ attribute, concatenating it to the end of the formatted current stack. Additionally, it should follow the exception chain using the __context__ or __cause__ attribute on the exception while concatenating the formatted traceback of each exception along the way.
Describe Alternatives
Looking for suggestions.
Additional context
Here's a short example:
# foo.py
import newrelic.agent
def c():
raise Exception("c")
def d():
try:
c()
except Exception as e:
raise Exception("d") from e
try:
d()
except:
newrelic.agent.notice_error()
Should report something like:
Traceback (most recent call last):
File "foo.py", line 17, in <module>
File "foo.py", line 13, in d
caused by: Exception('c')
Traceback (most recent call last):
File "foo.py", line 11, in d
File "foo.py", line 6, in c
Priority
Really Want
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.