I am not able to get Exceptions to be recorded by Elastic APM. It seems like Exception are handled by some other middleware and not released to Elastic middleware. I placed Use Elastic APM on the top of OnApplicationInitialization. That did not help. So far it seems only exceptions on EF core are caught by Elastic APM. I tested with general Exception thrown by me - even that Exception is not caught
- ABP Framework version: v7.X.X
- DB provider: EF Core
- Tiered (MVC) or Identity Server Separated (Angular): tiered
- Exception message and stack trace: -
- Steps to reproduce the issue:" I used this instruction https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net-core.html
7 Answer(s)
-
0
Hi,
Could you share the full steps to reproduce? thanks.
-
0
- Create new ABP Application
- Integrate Elastic following instruction https://www.elastic.co/guide/en/apm/agent/dotnet/current/configuration-on-asp-net-core.html
- Create and endpoint which throws some exception
- Call this endpoint and check Elastic APM
-
0
Hi,
I can't reproduce the problem with the steps you provided:
public override void OnApplicationInitialization(ApplicationInitializationContext context) { var app = context.GetApplicationBuilder(); var env = context.GetEnvironment(); app.UseElasticApm(app.ApplicationServices.GetRequiredService<IConfiguration>()); ....... } "ElasticApm": { "ServerUrl": "http://localhost:8200", "SecretToken": "", "ServiceName": "MyProjectName" }
public class IndexModel : MyProjectNamePageModel { public void OnGet() { throw new UserFriendlyException("Test exception"); } }
-
0
Please do these steps as well
- Create new Controller in HttpApi project
- Create some service in Application project, which throws an exception
- Make Controller call to call the service
-
0
Hi,
it's not a problem.
The elastic APM error page only shows unhandled exceptions
ABP automatically handles all exceptions and sends a standard formatted error message to the client for an API/AJAX request: https://docs.abp.io/en/abp/latest/Exception-Handling
-
0
How I can make APM also to catch Exceptions then? I want APM to catch exception before ABP does that. I guess APM proxies exception further
-
0
Hi,
Yes, you can do that.
You can define an exception subscriber: https://docs.abp.io/en/abp/latest/Exception-Handling#subscribing-to-the-exceptions
public class ElasticApmExceptionSubscriber : ExceptionSubscriber { public override Task HandleAsync(ExceptionNotificationContext context) { var transaction = Elastic.Apm.Agent.Tracer.CurrentTransaction; transaction.CaptureException(context.Exception); return Task.CompletedTask; } }