huseyinsimsekk / RimDev.AspNet.Diagnostics.HealthChecks

ASP.NET full framework implementation of ASP.NET Core health checks.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

RimDev.AspNet.Diagnostics.HealthChecks

ASP.NET full framework implementation of ASP.NET Core health checks.

Usage

The recommended installation method is the RimDev.AspNet.Diagnostics.HealthChecks NuGet package.

PM> Install-Package RimDev.AspNet.Diagnostics.HealthChecks

Then, use it like this in an OWIN Startup class:

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseHealthChecks(
            "/_health",
            new NoopHealthCheck(),
            new PingHealthCheck(new PingHealthCheckOptions().AddHost("localhost", 1000)));
    }
}

Usage with Health Checks UI

To use with the Health Checks UI project named health checks should be used and a special ResponseWriter needs to be configured. This returns the checks with more specific information about each check in a format that the UI project can read.

public class Startup
{
    public void Configuration(IAppBuilder app)
    {
        app.UseHealthChecks(
            "/_health_ui",
            new HealthCheckOptions
            {
                ResponseWriter = UIResponseWriter.WriteHealthCheckUIResponse
            },
            new HealthCheckWrapper(new NoopHealthCheck(), "Noop health check"),
            new HealthCheckWrapper(new PingHealthCheck(new PingHealthCheckOptions().AddHost("localhost", 1000)), "Ping to localhost"));
    }
}

The UI can't be hosted in a full framework app but can easily be setup using the official docker image for those who doesn't already have a UI project set up.

Requirements

  • .NET Framework 4.6.2 or later

License

MIT

About

ASP.NET full framework implementation of ASP.NET Core health checks.

License:MIT License


Languages

Language:C# 81.9%Language:PowerShell 18.0%Language:Batchfile 0.2%