Description
APM Agent version
1.26.0
Environment
Operating system and version:
N/A
.NET Framework/Core name and version
.NET 8.0.2
Application Target Framework(s) (e.g. net462, netcoreapp3.1):
net80
Describe the bug
In .NET 8 ASP.NET Core applications, the new IExceptionHandler<T>
exception handlers result in exceptions showing as Unhandled
in the APM UI even when they return true
to indicate the exception was handled.
To Reproduce
A reproduction is available here: ben-wallis@be1ac9d
Even though ArithmericExceptionHandler
in the above reproduction correclty handles the exception and returns true
the exception is still shown on the Errors tab as Unhandled in APM:
Exceptions handled by IExceptionHandler<T>
implementations emit the Microsoft.AspNetCore.Diagnostics.HandledException
diagnostic event, whereas those that are truly unhandled emit the Microsoft.AspNetCore.Diagnostics.UnhandledException
diagnostic event. Despite this difference, both diagnostic events result in the exception being captured as unhandled in AspNetCoreDiagnosticListener.cs
due to both of these diagnostic events being handled in the same code path: https://github.com/elastic/apm-agent-dotnet/blame/a82dba1e52b20f303c16a772c3fdfdbffcdbfb76/src/integrations/Elastic.Apm.AspNetCore/DiagnosticListener/AspNetCoreDiagnosticListener.cs#L77
Expected behavior
Handled exceptions are not shown as Unhandled in the APM UI
Actual behavior
Handled exceptions are shown as Unhandled in the APM UI