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

Group by Exception Message and Exception Type #160

Open
DeanGoodfynd opened this issue Aug 7, 2022 · 5 comments
Open

Group by Exception Message and Exception Type #160

DeanGoodfynd opened this issue Aug 7, 2022 · 5 comments
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature

Comments

@DeanGoodfynd
Copy link

Description

Bugsnag default grouping uses the Exception class to determine how to group error reports. However, many libraries written in Microsoft DotNet use a common exception Type and distinguish the particular cause of the error by the exception Message. This can cause BugSnag to lump together bugs that have very different causes.

Describe the solution you'd like
Ideally, I'd like to designate certain exception classes for which a combination of Exception Type and Exception Message will be used as the grouping discriminator (hash?).

Note that we probably don't want to use the Exception Message but rather the Exception Message Template. Often the Exception Message contains specifics about the error thrown, which may mean that the error messages won't get grouped at all. But I suspect this situation will improve as more libraries are updated to use structured logging.
https://docs.microsoft.com/en-us/aspnet/core/fundamentals/logging/?view=aspnetcore-6.0

For example, newer versions of Visual Studio encourage the use of structured message logging templates as part of code quality standards: https://docs.microsoft.com/en-us/dotnet/fundamentals/code-analysis/quality-rules/ca2254

Describe alternatives you've considered
Maybe we don't need to specify which C# classes need to be unpacked this way? If we can determine that MessageTemplate != Message, we know that structured logging is in effect, and we can just group bugs according to the structured logging rules.

Additional context
One key reason for requesting this feature is that we make use of many third-party libraries that we've brought in via NuGet packages. We don't have control over how these libraries throw errors. Sadly many of these providers throw a single exception type and use message to distinguish what happened.

One key example from the ecommerce domain: Stripe throws nearly everything as a StripeException, but with vastly different exception messages.

@luke-belton
Copy link
Member

Hi @DeanGoodfynd - thanks for raising this! We do already have an item on our backlog to look at grouping by error message, similar to the functionality we already offer for error context - I've noted your use case to our product team who will consider that in the future. I don't have an ETA for this work, however in the meantime I do have a couple of suggestions that you could use as a workaround.

Firstly you could consider updating the error context to the error message that you want to use for grouping, e.g. something like:

bugsnag.BeforeNotify(report => {
  report.Event.Context = report.OriginalException.Message;
});

Once you've set the context in this way, you can choose error classes in the Bugsnag dashboard that you wish to group by context on, in the usual way.

Your second option would be to consider using a custom grouping hash. This would probably look something like:

bugsnag.BeforeNotify(report => {
  if (report.OriginalException is StripeException) {
    report.Event.GroupingHash = report.OriginalException.Message;
  }
});

Hopefully you can adapt the above to work for the structured logging use case too!

@luke-belton luke-belton added feature request Request for a new feature backlog We hope to fix this feature/bug in the future labels Aug 8, 2022
@DeanGoodfynd
Copy link
Author

DeanGoodfynd commented Aug 8, 2022 via email

@luke-belton
Copy link
Member

Understood - I've noted that with our product team, too. Do let us know how you get on with implementing the workarounds - feel free to write into [email protected] if you'd prefer to carry on the conversation there 👍

@gareththackeray
Copy link
Contributor

Hi @DeanGoodfynd I'm only really aware of Message Templates with structured logging frameworks like Serilog, rather than with Exceptions. Could you explain how you get a Message Template from an Exception? Is this something you've added to your own Exception types perhaps?

@DeanGoodfynd
Copy link
Author

DeanGoodfynd commented Aug 18, 2022 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backlog We hope to fix this feature/bug in the future feature request Request for a new feature
Projects
None yet
Development

No branches or pull requests

3 participants