Skip to content
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

fix(NewRelicContextFormatter): add cause and context to stack traces #1266

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

sweco
Copy link

@sweco sweco commented Nov 29, 2024

Overview

NewRelicContextFormatter logs stack traces without causes which makes many errors hard to debug.

Let's take a look at the following code:

try:
    try:
        raise ValueError("First exception")
    except:
        raise ValueError("Second exception")
except Exception as e:
    logging.error("Encountered error", exc_info=e)

Before the PR, the exception message looked as follows:

  File ".../newrelic_exception_cause.py", line 60, in <module>
    raise ValueError("Second exception")

After the PR, it shows more details on the first cause:

Traceback (most recent call last):
  File ".../newrelic_exception_cause.py", line 58, in <module>
    raise ValueError("First exception")
ValueError: First exception
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
  File ".../newrelic_exception_cause.py", line 60, in <module>
    raise ValueError("Second exception")
ValueError: Second exception

Related Github Issue

No Github issue created.

Testing

Tests were updated to test a particular case where exception has a cause.

@CLAassistant
Copy link

CLAassistant commented Nov 29, 2024

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ sweco
❌ mergify[bot]
You have signed the CLA already but the status is still pending? Let us recheck it.

@sweco sweco marked this pull request as ready for review November 29, 2024 15:01
@sweco sweco requested a review from a team as a code owner November 29, 2024 15:01
@TimPansino
Copy link
Contributor

We'll give this a review after the US holiday season is over, we're going to avoid the risk of changing anyone's logs during this time period.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants