Atc.Rest.HealthChecks 4.1.0

dotnet add package Atc.Rest.HealthChecks --version 4.1.0
                    
NuGet\Install-Package Atc.Rest.HealthChecks -Version 4.1.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Atc.Rest.HealthChecks" Version="4.1.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Atc.Rest.HealthChecks" Version="4.1.0" />
                    
Directory.Packages.props
<PackageReference Include="Atc.Rest.HealthChecks" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Atc.Rest.HealthChecks --version 4.1.0
                    
#r "nuget: Atc.Rest.HealthChecks, 4.1.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Atc.Rest.HealthChecks@4.1.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Atc.Rest.HealthChecks&version=4.1.0
                    
Install as a Cake Addin
#tool nuget:?package=Atc.Rest.HealthChecks&version=4.1.0
                    
Install as a Cake Tool

Atc.Rest.HealthChecks

Target Framework: net10.0

Health check implementations and utilities for ASP.NET Core applications. Provides factories and helpers for creating JSON-formatted health check endpoints with detailed resource status information.

Why Use This Library?

Building robust health check endpoints requires consistent formatting and detailed status information. Atc.Rest.HealthChecks simplifies this by providing:

  • JSON Health Check Responses: Factory methods for JSON-formatted health checks
  • Resource Health Tracking: Track individual service/resource health status
  • Detailed Diagnostics: Include timing, status, and error details for each check
  • IReadOnlyDictionary Conversion: Helper extensions for health check data
  • Production-Ready Endpoints: Standardized health check responses

Perfect for:

  • Microservices requiring health endpoints
  • Kubernetes/container orchestration health probes
  • Load balancer health checks
  • Monitoring and observability solutions
  • API management platforms

Installation

dotnet add package Atc.Rest.HealthChecks

Target Framework

  • .NET 10.0

Key Features

  • HealthCheckOptionsFactory for creating JSON health check endpoints
  • ResourceHealthCheck class for tracking individual resource status
  • Extension methods for converting health data to IReadOnlyDictionary
  • Integration with Microsoft.Extensions.Diagnostics.HealthChecks
  • Support for custom health check implementations
  • MetricsHealthCheckPublisher to publish health check status and duration as metrics

Publishing health checks as metrics

AddMetricsPublisher() publishes the latest result of every health check on the meter MetricsHealthCheckPublisher.MeterName ("Atc.Rest.HealthChecks"), tagged health_check.name:

  • health_check.status: 0 = Unhealthy, 0.5 = Degraded, 1 = Healthy
  • health_check.duration: seconds
services.Configure<HealthCheckPublisherOptions>(o =>
{
    o.Delay = TimeSpan.FromSeconds(5);
    o.Period = TimeSpan.FromSeconds(30);
});

services
    .AddHealthChecks()
    .AddCheck<MyHealthCheck>("my-check")
    .AddMetricsPublisher();

// e.g. with OpenTelemetry
services.AddOpenTelemetry().WithMetrics(m => m.AddMeter(MetricsHealthCheckPublisher.MeterName));

Requirements

Key Dependencies

  • Microsoft.AspNetCore.App (framework reference)
  • Microsoft.Extensions.Diagnostics.HealthChecks (provided by Microsoft.AspNetCore.App)
  • Atc (foundation library)

Code documentation

References

References extended

Examples

The Startup.cs class in an API

using Microsoft.Extensions.Diagnostics.HealthChecks;

public class Startup
{
    private readonly JsonSerializerOptions jsonSerializerOptions;

    public Startup()
    {
        jsonSerializerOptions = Atc.Serialization.JsonSerializerOptionsFactory.Create();
    }

    public void ConfigureServices(IServiceCollection services)
    {
        services
            .AddHealthChecks()
                .AddCheck<MyHealthCheck>(
                    name: "MyHealthCheck",
                    failureStatus: HealthStatus.Unhealthy,
                    timeout: TimeSpan.FromSeconds(30));
    }

    public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
    {
        app.UseEndpoints(endpoints =>
        {
            endpoints.MapHealthChecks(
                "/health",
                HealthCheckOptionsFactory.CreateJson(
                    "ApplicationName.Api",
                    jsonSerializerOptions));
        });
    }
}

The MyHealthCheck class

public class MyHealthCheck : IHealthCheck
{
    public Task<HealthCheckResult> CheckHealthAsync(
        HealthCheckContext context,
        CancellationToken cancellationToken = default)
    {
        var data = new List<ResourceHealthCheck>();

        CheckSomeServices(data);

        if (data.All(x => x.Status == HealthStatus.Healthy))
        {
            return Task.FromResult(
                HealthCheckResult.Healthy(
                    "ApplicationName is healthy.",
                    data: data.ToIReadOnlyDictionary()));
        }

        return Task.FromResult(
            HealthCheckResult.Unhealthy(
                "ApplicationName is unhealthy.",
                exception: null,
                data: data.ToIReadOnlyDictionary()));
    }

    private void CheckSomeServices(
        ICollection<ResourceHealthCheck> data)
    {
        var sw = Stopwatch.StartNew();

        // Perform first HealthCheck and add a healthCheck to the data dictionary
        data.Add(
            new ResourceHealthCheck(
                "Service1",
                HealthStatus.Healthy,
                "Service1 is running.",
                sw.Elapsed));

        // Perform second HealthCheck and add a healthCheck to the data dictionary
        sw.Reset();
        data.Add(
            new ResourceHealthCheck(
                "Service2",
                HealthStatus.Unhealthy,
                "Service2 is not running.",
                sw.Elapsed));

        sw.Stop();
    }
}

Contributing

Contributions are welcome! Please see the main repository README for contribution guidelines.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • net10.0

    • Atc (>= 4.1.0)

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.1.0 179 11/9/2026
4.0.0 737 10/19/2026
3.0.186 2,415 8/25/2026
3.0.185 132 8/25/2026
3.0.181 1,019 7/29/2026
3.0.174 984 6/24/2026
3.0.173 172 6/24/2026
3.0.172 156 6/24/2026
3.0.67 1,583 4/25/2026
3.0.46 655 4/15/2026
3.0.45 319 4/10/2026
3.0.44 229 4/9/2026
3.0.43 148 4/9/2026
3.0.41 233 4/9/2026
3.0.40 194 4/9/2026
3.0.18 1,179 2/9/2026
3.0.16 547 12/15/2025
3.0.12 256 11/28/2025
3.0.9 439 11/21/2025
3.0.8 589 11/14/2025
Loading failed