Skip to content

[Feature] Reverse nested exceptions #3234

@vrobic

Description

@vrobic

Describe the feature you'd like

When nested exceptions occur, I'd like the last one to be listed in the DataDog Error Tracking, and not the first one.

Scenario

  1. An exception is thrown, let's name it A
  2. In a try/catch block, exception A is caught and a new exception B is thrown, with exception A as its previous one.

How DataDog handles it

Exception A will be listed in the DataDog Error Tracking as the main error, with B as the next one.

What I was expecting

As a PHP developer and according to PHP native behavior and other tools (including Symfony Profiler), I was expecting the exception B to be the main error, listed in the DataDog Error Tracking, with A as the previous one.

Here is the error.stack span attribute from a real world \PDOException:

Image

Image

In this example, I'd like to see the Symfony\Component\Messenger\Exception\HandlerFailedException listed in the DataDog Error Tracking, with its previous ones, just like this:

Image

Is your feature request related to a problem?

With exception A often being technical (eg. PDOException), and B being something more business oriented (eg. CouldNotSaveInvoiceException), it's difficult for our team to know what is the severity and user frustration of the errors listed in the DataDog Error Tracking.

Every backend developer in our team is from a PHP background and none of them were expecting to see the exception stack reversed.

Describe alternatives you've considered

No response

Additional context

A coworker of mine has found that this behavior is from ddtrace_exception_to_meta function in exception_serialize.c, with the dd_exception_to_error_msg and dd_exception_to_error_type functions being called with the overridden exception variable instead of the exception_root. This piece of code fixes #2498.

I'd like to discuss this with you. @PROFeNoM, as the developer who fixed the issue, can you give us your opinion please?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions