-
Notifications
You must be signed in to change notification settings - Fork 10.1k
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
Convert HealthChecks logging to use new Logging Source Generator #32414
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would prefer to keep the nested Log class |
And always pass in |
Yep. I don't like the log methods in the same class as where the logging happens |
Ok, sounds good. I'll move them back. Just to be sure, do we think the feature of finding the |
Oh, I remember why I did this now. The source generator doesn't support nested classes.
So I would need to move the |
OR fix issue? Is it possible to mark both as partial and make the current style work? |
It isn't possible today because this is an explicit limitation in the source generator. I opened dotnet/runtime#52301 to address it. |
@davidfowl - do you want me to wait for the source generator support for nested classes? Or should I address the other feedback in this PR to move it forward? |
I would do the places that don't need the nested class style change first (I think we have a few of them). |
I was just going to do 1 place as part of "app building" for preview4. This was the first one that jumped out to me 😄 . This PR can wait until the support comes in the source generator. |
* Keep nested Log class * Hard-code event names to ensure code refactoring doesn't lead to breaks
2775995
to
b6a021a
Compare
Thanks for all the feedback. I believe I have addressed it and this is now ready for review. PTAL. |
src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs
Outdated
Show resolved
Hide resolved
src/HealthChecks/HealthChecks/src/Microsoft.Extensions.Diagnostics.HealthChecks.csproj
Outdated
Show resolved
Hide resolved
@@ -12,6 +12,8 @@ Microsoft.Extensions.Diagnostics.HealthChecks.IHealthChecksBuilder | |||
<PackageTags>diagnostics;healthchecks</PackageTags> | |||
<IsAspNetCoreApp>true</IsAspNetCoreApp> | |||
<Nullable>enable</Nullable> | |||
<!-- workaround https://github.com/dotnet/roslyn/issues/52527 --> | |||
<NoWarn>$(NoWarn);SYSLIB1006</NoWarn> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Undo?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason this is still needed is because we are using an older Roslyn here:
Lines 161 to 162 in b9efadc
<!-- Packages from dotnet/roslyn --> | |
<MicrosoftNetCompilersToolsetVersion>3.10.0-1.final</MicrosoftNetCompilersToolsetVersion> |
That version didn't have the fix for dotnet/roslyn#52527
src/HealthChecks/HealthChecks/src/HealthCheckPublisherHostedService.cs
Outdated
Show resolved
Hide resolved
@Tratcher / @JamesNK / @BrennanConroy could you have a look at this PR and agree on the pattern for specifying event ids? It's the only part of that isn't mechanical. |
I think specifying them in the attribute is fine. Adding a static class with constants doesn't add anything. |
I think having the IDs in attributes is fine, but only if there isn't any other code in-between all the attributes like there is currently. As soon as you start putting random gaps in the grouping you make it a lot easier to introduce duplicate IDs. Clean: aspnetcore/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs Lines 211 to 215 in 0d037c0
Not clean: aspnetcore/src/HealthChecks/HealthChecks/src/DefaultHealthCheckService.cs Lines 227 to 253 in 0d037c0
|
I think we only need the static class for ids when multiple classes share a log category, then you want a central list to avoid duplicates. |
Doesn't the new logging generator check for duplicates? |
How does that work when the category is defined separately in the ILogger? |
Looks like they keep track of all IDs in a class |
In the case of KestrelTrace, there would still be one uber logging class, but we're passing in different ILogger instances to the various methods. Same design as today. The difference is just replacing the manually defined KestrelTrace with a mostly code-generated one. |
Is there a recommendation on what to do in this PR? I'm totally fine with making a change to remove the Personally, I'd lean to keep it as-is because:
|
I guess the consensus seems to be to inline the Ids which we could do in other updates if we need to. In particular because this PR has tests that reference these events, I'm fine with them being in a separate type. If folks feel super strong about this, please chime in. Otherwise let's get this change in. |
[main] Update dependencies from dotnet/efcore dotnet/runtime - Workaround duplicate logging source generator - Merge branch 'main' into darc-main-1709b9ed-50a0-4e28-b9b8-0e3759aee720 - Fix CS8795 https://dev.azure.com/dnceng/public/_build/results?buildId=1222936&view=logs&jobId=b5df7d42-2bda-5dee-96bd-1838a4f7499c&j=b5df7d42-2bda-5dee-96bd-1838a4f7499c&t=c1ffdaa9-e800-5fe8-052c-643f2e9f52ff - Update Wasm.Performance.TestApp.csproj - Fix skipEnabledCheck - Merge branch 'main' into darc-main-1709b9ed-50a0-4e28-b9b8-0e3759aee720 - Update Workarounds.targets - Revert "Fix CS8795" This reverts commit a2ec9d6. - Revert "Convert HealthChecks logging to use new Logging Source Generator (#32414)" This reverts commit 1dd00f4. - Utilize class level SkipEnabledCheckLogOptions - React to MvcCoreLoggerExtensions feedback - Merge remote-tracking branch 'origin/main' into darc-main-1709b9ed-50a0-4e28-b9b8-0e3759aee720 - React to nullability changes in TypeConverter - Merge branch 'main' into darc-main-1709b9ed-50a0-4e28-b9b8-0e3759aee720 - React to new analyzer warnings - Revert "Revert "Convert HealthChecks logging to use new Logging Source Generator (#32414)"" This reverts commit 5d6e21e. - Update src/Http/Routing/src/Matching/DfaMatcher.cs Co-authored-by: Eric Erhardt <[email protected]> - Update exception caught in HTTP2 tests - Merge branch 'main' of https://github.com/dotnet/aspnetcore into darc-main-1709b9ed-50a0-4e28-b9b8-0e3759aee720 - Revert "Remove usings from templates implicitly added by the SDK (#34219)" This reverts commit d8bba72. - Fix up exceptions for HTTP2 tests - Revert "Revert "Remove usings from templates implicitly added by the SDK (#34219)"" This reverts commit cce1bd7. - Bump up SDK to bring in usings changes - Try running template tests on non-Helix - Update ci.yml - Try disabling template tests on Helix - Revert "Stop running template tests on azdo job (already helix-ified) (#32985)" This reverts commit 7a842b7. - Don't build Helix payload for template tests - Temporarily skip FrameworkListListsContainsCorrectPaths - Use dotnet test for test discovery - Revert "Use dotnet test for test discovery" This reverts commit f5cecb2. - Try skipping listing tests list in helix - Revert "Try disabling template tests on Helix" This reverts commit 2136f31. - Remove generic type from test method - Removed another generic from the test method
In the latest 6.0-preview docker image, the logger message arguments are mixed up: This is probably a source generator issue, but I can't figure out whether it has already been fixed. cc: @maryamariyan |
Hi @danielcweber. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
Note: I debugged into the repro at #34710. I noticed that this PR isn't in 6.0.0-preview6. It was merged after the preview6 snap. So the issue existed before my change. |
Hi @eerhardt. It looks like you just commented on a closed PR. The team will most probably miss it. If you'd like to bring something important up to their attention, consider filing a new issue and add enough details to build context. |
PR Title
Convert HealthChecks logging to use new Logging Source Generator
PR Description
Simplying the HealthChecks logging code by using the new Logging source generator feature.
See dotnet/runtime#36022
cc @maryamariyan