Skip to content

Provide common IHealthCheckPublisher implementation #53670

Open
@thompson-tomo

Description

@thompson-tomo

Summary

I want to have some general Health publisher's available which publish to common targets ie log file, System.Diagnostic.

Motivation and goals

I want to make it as easy as possible for developers to be able record the results of the configured health checks and monitor them over time. It should not matter if on-premise or cloud software.

With this change I will be able to collect log files from site & to see what the health has been for a period of time. Note A key thing would be to ensure that appropriate log levels are used

In scope

Release of new nuget package

  • Microsoft.Extensions.Diagnostics.HealthChecks.Publishers.Logger which is used to write health info to logs during development & offline cases etc
  • Microsoft.Extensions.Diagnostics.HealthChecks.Publishers.DiagnosticticSource which is used to write health info as metrics and can then be processed by other tools ie otel collectors

Out of scope

Supporting any logger other Microsoft.Extensions.Logger

Examples

The idea is to make it as simple for developer to enable and as such the idea would be:

builder.Services.AddHealthPublisherLogger();

Or

builder.Services.AddHealthPublisherDiagnosticSource();

Obviously it should be possible to define the HealthCheckPublisherOptions just like if it was explicitly added.

Detailed design

To eliminate log spam The following mapping of the health status is needed.

  • Error first instance of a failure
  • Warning subsequent instance of a failed health check
  • Info first instance of a service going healthy
  • Debug subsequent instance of a healthy health check

For diagnostic source the key thing is all the attributes of report data are exposed as attributes.

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-healthchecksIncludes: Healthchecks (some bugs also in Extensions repo)design-proposalThis issue represents a design proposal for a different issue, linked in the description

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions