Exception Filtering
lxcodes opened this issue · comments
Currently, referencing this:
To circumvent this, plan on adding the ability to set a series of patterns that you can use to exclude
exceptions based on exception type, part of the message, or something along those lines.
Is this a way to filter exceptions with the HttpModule or would this refer to filtering by capturing errors with local blocks specific to the exceptions I would like to catch?
If it is the later, would you be willing to accept a pull request for exception filtering based on a configuration variable? The documentation notes that a 404 would be reported, but it seems that 404s and HttpExceptions have been forcefully excluded in the module itself.
if (!(exception is HttpException) || ((HttpException)exception).GetHttpCode() != 404)
exception.SendToAirbrake();
👍 This is still a needed feature.
The airbrake-js notifier handles filtering with an addFilter method that is very useful, sharpbrake should have something similar.
We added airbreak to an old .NET project and have over 10k errors form 404s alone on one project. Every time a bot hits the site we go over our limits. This is a much needed feature.
With new Sharpbrake we have released a new version of HttpModule as well (and middleware for new ASP.NET Core pipeline architecture). One of our tutorials describes how to ignore HTTP 404 Not Found exception. You can also use manual exception reporting and, in that case, there are two possibilities: you can either 1) "catch" only exceptions that should be reported or "catch" all but notify only on interested one (as Alexander has described in his comment above):
try
{
// ...
}
catch (HttpException ex)
{
if (ex.GetHttpCode() == 404)
return;
var airbrake = (AirbrakeHttpModule)HttpContext.ApplicationInstance.Modules["Airbrake"];
airbrake.GetNotifier().Notify(ex, new AspNetHttpContext(System.Web.HttpContext.Current));
}
try
{
// ...
}
catch (Exception ex)
{
var httpException = ex as HttpException;
if (httpException == null || httpException.GetHttpCode() == 404)
return;
var airbrake = (AirbrakeHttpModule)HttpContext.ApplicationInstance.Modules["Airbrake"];
airbrake.GetNotifier().Notify(ex, new AspNetHttpContext(System.Web.HttpContext.Current));
}
or 2) you can add filter that will ignore certain exception types.
Please, let me know if you need more information on filtering what should be sent to Airbrake.
I hope that either one of the solutions above works for you. Please, let us know what other features you would like to see in our new notifier. Thank you.