levibostian / ExpressjsBlanky

Blank Express.js project to get up and running FAST.
MIT License
7 stars 0 forks source link

Separation of errors in Honeybadger #38

Closed levibostian closed 4 years ago

levibostian commented 4 years ago

This project uses Honeybadger to report when errors occur.

The problem is that many errors are being grouped together within Honeybadger.

For example, when Sequelize hits a unique constraint exception, honeybadger records a "Validation error". This is a very generic error thrown by Sequelize when any unique constraint happens.

When a sequelize unique constraint exception happens, for any endpoint, for any query, any of our lines of code, the same 1 single error is recorded in Honeybadger.

This makes errors in Honeybadger quite difficult to process. We could have 1 error recorded but this error is happening on 3 different endpoints.

Proposal

Go through honeybadger docs to learn more about how errors are grouped together. This will teach us how we can make sure that honeybadger errors are unique when they are recorded.

levibostian commented 4 years ago

After reading docs and source code for honeybadger, I have found out how errors are grouped in honeybadger.

According to the honeybadger API docs...

The backtrace key of the error hash is essential, as that is used for grouping similar errors together in the Honeybadger UI. The class and message keys of the error hash are displayed in the Honeybadger UI and used for posting errors to other services, like Github issues.

Looking at the honeybadger node module source, the backtrace is a stacktrace. That means that the stacktrace must be unique in order to prevent grouping.

That means that you could have different API endpoints, different Error classes, different messages all grouped into 1 error. This has been happening to me. My stacktraces are not very unique when libraries like sequence have an error:

2020-10-27 at 2 16 PM

This stacktrace has no value in it at all. The error from sequelize is valuable because it is the error from the postgres query. But besides that, the stacktrace should be the stacktrace from my apps code. That would make it helpful and not grouped. The only way to avoid not grouping is a unique stacktrace.

The class and message are still important. They should be unique for each type of problem that can occur. They are used for the developers to easily glance at in a list:

2020-10-27 at 2 24 PM

You can see that I am repeating the generic "Error" class name for most of these making it not helpful. The pixelated text is there for privacy, but note that they are actually all the same meaning that the stacktraces are unique but the messages are all the same.

levibostian commented 4 years ago

Done