Skip to content

Support for Chained Exception Tracebacks #496

Description

@fliu98

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature-requestRequest for new or enhanced features.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions