APM .net agent errors

Hello, i have been playing arround with elastic apm .net agent and i have some questions/doubts i was hoping someone could help.
Im using .net 6 with "UseAllElasticApm" which works just fine for my HTTP requests.
My issue is with the exceptions handling how these are displayed in the APM errors view.

I have a custom filter in my app that captures any exception and handles it, like this:

public async override Task OnExceptionAsync(ExceptionContext context)
    {
        logger.LogError(context.Exception, context.Exception.Message);
        context.Result = new StatusCodeResult(500);
        context.ExceptionHandled = true;
    }

When i do this, i do not see any errors in my elastic apm view (in the errors tab). If i re throw the exception, then i see the errors but my app behavior changes (i have other middlewares that are not expecting to receive the exception).

Is this the normal behavior? If yes, what can i do in order to keep my exception filter handling my exceptions but at the same time, having my app errors being displayed in the apm view?

Thank you in advance!

EDIT:
Is this a good approach to handle my problem?
Agent.Tracer.CurrentTransaction.CaptureException(context.Exception);

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.