Custom error grouping for .NET Exceptions

Jamie.NET, Product Updates, Provider Updates3 Comments

Raygun tries its hardest to group your exceptions together intelligently, but it’s a hard problem to solve and we don’t always get it right for everyone. To help with this, we’ve added the ability to define your own grouping hash for .NET exceptions before you send them.

What is a group hash?

It’s the key that tells Raygun which error group the error should go into. Generally the payload hits the Raygun servers, which runs a hashing algorithm over it and sorts it into the correct group. This works 99.99% of the time – your errors show up exactly where you expect them and everybody is happy.

Of course there is always the chance that Raygun’s hasher doesn’t group your error how you desire.

What are my options?

We have two options to get around this problem:

  1. Use message based hashing, but this has limitations the second you have two messages that are the same but have very different causes.
  2. Now you can also provide your own hashing key!

What does providing your own hashing key involve?

It’s quite easy. You attach an event handler to RaygunClient, which gives you the Exception and the RaygunMessage that Raygun4NET has created, and you send back the key you want to use for grouping that error. If you don’t set a grouping key, we use our normal hashing routine.

Here’s the basic idea:

This will set the custom grouping key for any SqlException to be the string “SqlException” plus the error number of the underlying SQL error, so any SqlExceptions will be grouped together as long as they have the same error number. Not only that, but other exceptions will still be grouped normally by Raygun. Great!

The grouping key you produce should probably be less than 100 characters – we don’t actually restrict you here, but if it’s longer than that we will SHA1 hash your key and use the results of that. It’s quite unlikely that this will produce duplicates, but it’s worth mentioning.

WARNING – Custom error hashing should be a last resort for when the built-in hashers don’t quite suit you – but as always, the more choices you have the better!

We would absolutely recommend Raygun to any business which relies on healthy software to serve there customers. Andrew Schofield, Chief technology officer at Timely. Take a free 14 day trial. Request a short demo of Raygun.

3 Comments on “Custom error grouping for .NET Exceptions”

  1. Nate Cook

    Why is it that, when I use CustomGroupingKey, the message in the Raygun list view no longer prepends the Exception type nor the HttpMethod info (e.g. Returned while handling PUT request)? I still want to see that.

  2. Jason Fauchelle

    Hi Nate,

    Thanks for your comment. This is an oversight on our part. The logic for creating a name for each group of exceptions is managed by the same classes that provide the built-in grouping logic. When you do provide a grouping key, we skip going through our grouping logic of course, but this ends up skipping the group naming logic too. I think we should still use the group naming logic, though I’m not sure when we’ll implement this sorry.

  3. Pingback: Provider Update: Custom Error Grouping For PHP - The Raygun Blog

Leave a Reply

Your email address will not be published. Required fields are marked *