[feature request] Minimal API Exception recording #2230
Labels
comp:instrumentation.aspnetcore
Things related to OpenTelemetry.Instrumentation.AspNetCore
enhancement
New feature or request
Component
OpenTelemetry.Instrumentation.AspNetCore
Is your feature request related to a problem?
If an exception is thrown during a call to a Minimal API, the exception is not recorded as a span event, even with
RecordException
set to true duringAddAspNetCoreInstrumentation
setup.What is the expected behavior?
An unhandled exception is recorded as a span event.
Which alternative solutions or features have you considered?
It's possible this occurs because Minimal APIs lack much of the pipeline of traditional controller endpoints (e.g exception handling). This may then be considered consistent with the core ASP NET framework but really isn't a great experience for the user as it's not obvious or intuitive why the event isn't present. The span has an error status but there's no information about the exception (e.g the stack trace) which makes it impossible get to the root of the problem and is a pretty unpleasant scenario if you don't notice this is occurring until you need to debug an issue with a Minimal API in production.
If it's determined this is the expected behavior and this isn't a bug, it would be good for this to at least be documented - perhaps with a snippet of code showing how to ensure events are written (custom
IExceptionHandler
?).Personally I think the default behavior should be to record exceptions as span events across both controller and minimal APIs, without having to manually set
RecordException
to true. This information is arguably the most important element to dispatch to your APM.Additional context
No response
The text was updated successfully, but these errors were encountered: