sentry-dotnet
sentry-dotnet copied to clipboard
Filter out EF Core internal log in Sentry.Extensions.Logging
Please mark the NuGet packages used:
- [x] Sentry.Extensions.Logging
By default the package should exclude an internal error log from EF Core. It logs as error (with a stack trace that is not helpful) right before throwing.
The user code would anyway log that error once it captures the exception. Or Sentry would log that anyway if unhandled.
c.AddLogEntryFilter((category, level, eventId, exception)
=> eventId.Id == 10000
&& string.Equals(eventId.Name, "Microsoft.EntityFrameworkCore.Update.SaveChangesFailed", StringComparison.Ordinal)
&& string.Equals(category,"Microsoft.EntityFrameworkCore.Database.Command", StringComparison.Ordinal));
Thanks @kanadaj for raising and proposing the filter.
@bruno-garcia This might need an integration test (we'd want to monitor the behaviour inside an asp.net core request both with and without a try-catch in the Action), but I believe there isn't one set up currently so this might be a problem.
@bruno-garcia I think the "stack trace that is not helpful" part of this is related to #455
Yes. The Sentry SDK is doing it's job and logging something as it was provided to it. EF Core though is logging in the middle which doesn't include the stack trace. This issue suggest just dropping that log entry altogether (since it'll be logged once rethrown)