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

Provide a way to opt out of automated tracking of handled exceptions #2922

Open
nulltoken opened this issue Dec 10, 2024 · 0 comments
Open
Labels

Comments

@nulltoken
Copy link

Microsoft.ApplicationInsights.AspNetCore" Version="2.22.0"

  • Runtime version (e.g. net461, net48, netcoreapp2.1, netcoreapp3.1, etc. You can find this information from the *.csproj file):

net8.0

  • Hosting environment (e.g. Azure Web App, App Service on Linux, Windows, Ubuntu, etc.):

Azure Web Apps

Describe the bug

Follow up to #2645. Similar use case, but more scoped (as there's no relation to ILogger)

Leveraging builder.Services.AddApplicationInsightsTelemetry(...), IExceptionHandler interceptors and app.UseExceptionHandler(builder => { });
doesn't seem to play well together.

Indeed, although some Exceptions are handled in the IExceptionHandler implementations (by returning having the TryHandleAsync method return true), those are still tracked in ApplicationInsights.

Which leads to some pollution with a lot of unwanted Exceptions being tracked.

else if (this.trackExceptions && value.Key == "Microsoft.AspNetCore.Diagnostics.HandledException")
{
httpContext = this.httpContextFetcherDiagExceptionHandled.Fetch(value.Value) as HttpContext;
exception = this.exceptionFetcherDiagExceptionHandled.Fetch(value.Value) as Exception;
if (httpContext != null && exception != null)
{
this.OnDiagnosticsHandledException(httpContext, exception);
}
}

Would there be a way to opt out of this automatic tracking?

To Reproduce

If the above information is not enough, would this need to a end to end repro case, please let me know and I'll take the time to craft one.

@nulltoken nulltoken added the bug label Dec 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant