Skip to content

DbContextHealthCheck should properly log all failure exception by default #62600

@im-aIex

Description

@im-aIex

Is there an existing issue for this?

  • I have searched the existing issues

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

The current default implementation of DbContextHealthCheck uses dbContext.Database.CanConnectAsync(token) to determine the health status of the DB. The implementation of CanConnectAsync swallows errors and only returns true/false based on if it was able to connect or not. This does not give adequate details when health checks fail.

Describe the solution you'd like

Update the default implementation of DbContextHealthCheck to properly log and have the health result contain any exceptions thrown when attempting to connect to the DB. This could either be just using its own "SELECT 1" logic or changing the default implementation to call ExistsAsync instead, since CanConnectAsync is just a wrapper around ExistsAsync that swallows errors.

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