Skip to content

Fix missing handled tag when events are logged via an ASP.NET Core pipeline logger - #1284

Merged
bruno-garcia merged 11 commits into
getsentry:mainfrom
kanadaj:main
Nov 1, 2021
Merged

bruno-garcia merged 11 commits into
getsentry:mainfrom
kanadaj:main

Conversation

@kanadaj

@kanadaj kanadaj commented Oct 22, 2021 •

Copy link
Copy Markdown
Contributor

Fixes #1283

This is a draft fix for an issue with the Serilog sink that causes issues not to be marked as handled.

Realistically this should have a test written for it, but I have no idea how to mock the entire ASP.NET Core pipeline, and testing this would require that. Also not entirely sure if this is the best way to handle this. Maybe an event processor could also do this instead?

@bruno-garcia @lucas-zimerman thoughts?

@bruno-garcia

Copy link
Copy Markdown
Member

@codecov-commenter

codecov-commenter commented Oct 22, 2021 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.54%. Comparing base (a65e1ac) to head (c9d97c5).
⚠️ Report is 2416 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1284      +/-   ##
==========================================
+ Coverage   81.83%   82.54%   +0.70%     
==========================================
  Files         212      213       +1     
  Lines        7075     7085      +10     
  Branches     1396     1399       +3     
==========================================
+ Hits         5790     5848      +58     
+ Misses        845      801      -44     
+ Partials      440      436       -4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@kanadaj

kanadaj commented Oct 22, 2021

Copy link
Copy Markdown
Contributor Author

You can test in:

https://github.com/getsentry/sentry-dotnet/blob/main/test/Sentry.AspNetCore.Tests/IntegrationsTests.cs

Will have to add Serilog as a dependency of the AspNetCore project then. And NLog. This will get ugly.

@kanadaj
kanadaj marked this pull request as ready for review October 22, 2021 20:30
@kanadaj kanadaj changed the title Candidate fix for https://github.com/getsentry/sentry-dotnet/issues/1283 Fix missing handled tag when events are logged via an ASP.NET Core pipeline logger Oct 22, 2021
@kanadaj

kanadaj commented Oct 22, 2021

Copy link
Copy Markdown
Contributor Author

Okay, got a proper candidate now. Ended up using an exception processor instead, just to cover all the different loggers in one move, and also added an integration test to the Serilog tests repo. A lot of boilerplate there to make it work, but it seems better than adding Serilog specific integration tests to the AspNetCore test project (might also need tests for this also for NLog and Microsoft.Extensions.Logging?)

@bruno-garcia

Copy link
Copy Markdown
Member

Thanks for the PR.
I wonder if the FakeServer stuff could go into Sentry.Testing and there we can add dependency to ASP.NET, for example.

Hopefully @lucas-zimerman and/or @SimonCropp can help out with the review here

@kanadaj

kanadaj commented Oct 26, 2021

Copy link
Copy Markdown
Contributor Author

Thanks for the PR. I wonder if the FakeServer stuff could go into Sentry.Testing and there we can add dependency to ASP.NET, for example.

We could just make it in Sentry.AspNetCore.Testing public and add a dependency to that instead.

Though, will still need to override the fake anyway for the custom logging config.


Assert.Equal("Microsoft.AspNetCore.Diagnostics.ExceptionHandlerMiddleware", LastEvent?.Logger);
Assert.Same(expectedException, LastExceptionFilter.LastException);
Assert.Collection(LastEvent.SentryExceptions, x => Assert.False(x.Mechanism?.Handled));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can u fix the GH action checks

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works locally, I wonder why it breaks on GH Actions. I've changed the tests, will see if it works correctly now.

Co-authored-by: LucasZF <lucas-zimerman1@hotmail.com>
@bruno-garcia
bruno-garcia enabled auto-merge (squash) November 1, 2021 20:08
@bruno-garcia

Copy link
Copy Markdown
Member

@kanadaj Thanks for the PR.
Could you please add to changelog:

Fix missing handled tag when events are logged via an ASP.NET Core pipeline logger ([#1284](getsentry/sentry-dotnet/pull/1284))

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sentry doesn't correctly set error.unhandled, so issues don't appear on the Sentry project page

5 participants