Skip to content

Make it optional to register HealthCheckPublisherHostedService when using AddHealthChecks #29896

Open
@tobiaswatzek

Description

@tobiaswatzek

Is your feature request related to a problem? Please describe.

I am trying to use the Microsoft.Extensions.Diagnostics.HealthChecks library in a project but I don't want to register the default HealthCheckPublisherHostedService which is automatically registered when the AddHealthChecks extension method is used. I still would like to use the DefaultHealthCheckService and the HealthChecksBuilder which unfortunately are all marked as internal which means that I would have to implement them again in my code.

What I want to do is running my health checks manually with the help of the DefaultHealthCheckService inside of an Orleans cluster. The reason why I don't want to register the HealthCheckPublisherHostedService is that it would execute and publish all health checks on each node periodically which is unnecessary.

Describe the solution you'd like

I would like a method similar to AddHealthChecks or a parameter for AddHealthChecks to control if the HealthCheckPublisherHostedService gets registered or not.

Additional context

The corresponding code which registers the HealthCheckPublisherHostedService can be found here:

services.TryAddEnumerable(ServiceDescriptor.Singleton<IHostedService, HealthCheckPublisherHostedService>());

Metadata

Metadata

Assignees

No one assigned

    Labels

    affected-fewThis issue impacts only small number of customersarea-healthchecksIncludes: Healthchecks (some bugs also in Extensions repo)enhancementThis issue represents an ask for new feature or an enhancement to an existing oneseverity-minorThis label is used by an internal tool

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions