Skip to content

HealthCheck APIs need to be recompiled to fix source generation for LoggerMessages #34710

Closed

Description

@danielcweber

Follow up to #34709.

Describe the bug

In the current preview builds of .NET 6.0, the output of the DefaultHealthCheckService is broken (arguments are switched). This is probably due to a change in the HealthCheck Apis and/or a bug in the LoggerMessage source generator (that seems to be fixed now if there was one).

To Reproduce

Run https://github.com/danielcweber/AspLoggerMessageBugRepro2 and navigate to the /health endpoint. It'll output something like

Health check processing with combined status 18.1081 completed after Healthyms

I recreated the whole source generation of this specific HealthCheck-Api part without any issues. So I figure that things just need to be rebuilt.

Further technical details

  • ASP.NET Core version:
    6.0.0-preview.6.21353.1

  • Include the output of dotnet --info

.NET SDK (gemäß "global.json"):
Version:   6.0.100-preview.6.21355.2
Commit:    7f8e0d76c0

Laufzeitumgebung:
OS Name:     Windows
OS Version:  10.0.19043
OS Platform: Windows
RID:         win10-x64
Base Path:   C:\Program Files\dotnet\sdk\6.0.100-preview.6.21355.2\

Host (useful for support):
 Version: 6.0.0-preview.6.21352.12
 Commit:  770d630b28

.NET SDKs installed:
 3.1.411 [C:\Program Files\dotnet\sdk]
 5.0.101 [C:\Program Files\dotnet\sdk]
 5.0.104 [C:\Program Files\dotnet\sdk]
 5.0.205 [C:\Program Files\dotnet\sdk]
 5.0.301 [C:\Program Files\dotnet\sdk]
 5.0.302 [C:\Program Files\dotnet\sdk]
 6.0.100-preview.6.21355.2 [C:\Program Files\dotnet\sdk]

.NET runtimes installed:
 Microsoft.AspNetCore.All 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
 Microsoft.AspNetCore.All 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.All]
 Microsoft.AspNetCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.AspNetCore.App 6.0.0-preview.6.21355.2 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
 Microsoft.NETCore.App 2.1.28 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 2.2.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.NETCore.App 6.0.0-preview.6.21352.12 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
 Microsoft.WindowsDesktop.App 3.1.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 3.1.17 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 5.0.4 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 5.0.7 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 5.0.8 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
 Microsoft.WindowsDesktop.App 6.0.0-preview.6.21353.1 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
  • The IDE (VS / VS Code/ VS4Mac) you're running on, and its version
    Microsoft Visual Studio Professional 2022 Preview (64-bit)
    Version 17.0.0 Preview 2.1

Activity

  1. eerhardt commented on Jul 26, 2021

    @eerhardt
    Member

    Note: I debugged into this repro. I noticed that my PR (#32414) to change HeathChecks to use the source generator isn't in 6.0.0-preview6. It was merged after the preview6 snap.

    So the issue existed before my change.

  2. eerhardt commented on Jul 26, 2021

    @eerhardt
    Member

    I believe the issue was here:

    private static readonly Action<ILogger, double, HealthStatus, Exception?> _healthCheckProcessingEnd = LoggerMessage.Define<double, HealthStatus>(
    LogLevel.Debug,
    EventIds.HealthCheckProcessingEnd,
    "Health check processing with combined status {HealthStatus} completed after {ElapsedMilliseconds}ms");

    _healthCheckProcessingEnd(logger, duration.TotalMilliseconds, status, null);

    Notice that the order of arguments is flipped. duration.TotalMilliseconds first, status second in the method call. But in the string, {HealthStatus} first and {ElapsedMilliseconds}ms second.

    I fixed the ordering in my change, which should be in preview7.

    [LoggerMessage(EventIds.HealthCheckProcessingEndId, LogLevel.Debug, "Health check processing with combined status {HealthStatus} completed after {ElapsedMilliseconds}ms", EventName = EventIds.HealthCheckProcessingEndName)]
    private static partial void HealthCheckProcessingEnd(ILogger logger, HealthStatus HealthStatus, double ElapsedMilliseconds);

  3. mkArtakMSFT commented on Jul 26, 2021

    @mkArtakMSFT
    Contributor

    Thanks @eerhardt!
    Looks like you left no action pending here.

  4. ghost locked as resolved and limited conversation to collaborators on Aug 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-healthchecksIncludes: Healthchecks (some bugs also in Extensions repo)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions