AspNetCore - How to Filter Out OpenIdConnect "errors"

Does someone have a code example on how to filter out messages before they are sent to Sentry in the AspNetCore integration?

The Ignore option via the website doesn’t work because each of the errors has a unique GUID in it.

At a high level, after enabling Sentry we are getting lots of B2C / OpenIdConnect “error” in our Sentry logs. OpenIdConnect sends an “error” to your website on “forgot password” and other events so you can handle them in a custom way. (See below for more details.)

I took a look at the docs, but curious if someone had an example:

Application Insights treats these messages as non-errors. We have a Small Subscription so can’t use Server Side Error Message Filters, etc.

Thanks in advance!

More details:

Example OpenIdConnect code to handle the "Error" that is not really an error:

Example Errors:

There are two style of errors that we want to ignore. The first lines of each message are always identical.


  1. Cancelled

Message contains error: ‘access_denied’, error_description: 'AADB2C90091: The user has cancelled entering self-asserted information.

Correlation ID: b638e06b-xxxx-xxxx-xxxx-3ff066f7a8b1

Timestamp: 2018-10-01 20:54:13Z

', error_uri: ‘error_uri is null’.

  1. Forgot password

Message contains error: ‘access_denied’, error_description: 'AADB2C90118: The user has forgotten their password.

Correlation ID: bf1901d4-xxxx-xxxx-xxxx-e52c8783015a

Timestamp: 2018-10-01 20:47:42Z

login_hint: xxxxxx

', error_uri: ‘error_uri is null’.

One of the other devs on the team found a solution. This one uses SetFingerprint to group all the events with different GUIDs together… (I like this better than completely suppressing the messages.)

This will let us ignore all the similar messages as a group in the Sentry web interface.

Looks like this.

        .UseSentry(o => 
            { o.BeforeSend = sentryEvent =>
                                        sentryEvent.SetFingerprint(new List<string>(){ "AADB2C90091"});
                                    else if(sentryEvent.Message.Contains("'AADB2C90118"))
                                        sentryEvent.SetFingerprint(new List<string>() { "AADB2C90118" });
                                    return sentryEvent;