Hi,
I’m trying to indicate the .NET APM client that the following exception, thrown from EF Core is properly handled:
catch (DbUpdateException exception) when
(exception.InnerException is PostgresException
{
TableName: "my_table", SqlState: PostgresErrorCodes.UniqueViolation
})
{
Just after {
, I put:
ITransaction currentTransaction = tracer.CurrentTransaction;
currentTransaction.CaptureException(exception, isHandled: true);
tracer.CaptureException(exception, isHandled: true);
And the exception is not thrown again, in fact, there is an Minimal API return TypedResults.Created(CreateTransactionRequest.Route);
at the end of this handle.
However, with the help of Agent.AddFilter
and Kibana APM view, I noticed that related errors, that is, this unique violation exception, are sent regardless.
From Kibana (top) and Agent.AddFilter
(bottom):
Clearly, there are some remains of this failure being sent to APM server.
I’m guessing that,
builder.Services.AddAllElasticApm();
, which is how we set up, subscribes to EF Core and intercept its errors, I don’t know.
This is a controlled environment (Docker compose with Elastic stack), simulating what we are experiencing in our instance.
Is it possible to filter out these related logs, exceptions, etc, reliably? Or comparing string within the Agent.AddFilter
handler the only way?
Mind you, I may not be able to capture all 4 types of error, because error.Context
is not the same from ITransaction currentTransaction = tracer.CurrentTransaction
from before, so I cannot “mark it“ and later check the context for an entry, say “is_unique_validation_exception“.
Kibana version:8.17
Elasticsearch version:8.17
APM Server version:8.17
APM Agent language and version: C#/.NET 9.0, ver: 1.34
Is there anything special in your setup? No.