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

[feature request] Minimal API Exception recording #2230

Open
domholmes opened this issue Oct 21, 2024 · 2 comments
Open

[feature request] Minimal API Exception recording #2230

domholmes opened this issue Oct 21, 2024 · 2 comments
Labels
comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore enhancement New feature or request

Comments

@domholmes
Copy link

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 during AddAspNetCoreInstrumentation 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

@domholmes domholmes added the enhancement New feature or request label Oct 21, 2024
@github-actions github-actions bot added the comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore label Oct 21, 2024
@xiang17
Copy link
Contributor

xiang17 commented Oct 24, 2024

Can you provide a minimal reproduce app for this?

@domholmes
Copy link
Author

Can you provide a minimal reproduce app for this?

Is an exception being recorded as a span event during a minimal API call the expected behaviour? If so it's probably best we convert this to a Bug Report and I can create a repro.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp:instrumentation.aspnetcore Things related to OpenTelemetry.Instrumentation.AspNetCore enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants