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

Filter out EF Core internal log in Sentry.Extensions.Logging #454

Closed
1 task done
bruno-garcia opened this issue Jun 22, 2020 · 3 comments · Fixed by #1980
Closed
1 task done

Filter out EF Core internal log in Sentry.Extensions.Logging #454

bruno-garcia opened this issue Jun 22, 2020 · 3 comments · Fixed by #1980
Assignees
Labels

Comments

@bruno-garcia
Copy link
Member

bruno-garcia commented Jun 22, 2020

Please mark the NuGet packages used:

  • 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.

@kanadaj
Copy link
Contributor

kanadaj commented Jun 22, 2020

@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.

@Cooksauce
Copy link

@bruno-garcia I think the "stack trace that is not helpful" part of this is related to #455

@bruno-garcia
Copy link
Member Author

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

5 participants