An open API service indexing awesome lists of open source software.

https://github.com/kpol/healthcheckr

A lightweight health check library for .NET and Azure Functions that runs async checks in parallel, preserves execution order and returns a clean JSON response with status, durations and optional error details.
https://github.com/kpol/healthcheckr

Last synced: 5 months ago
JSON representation

A lightweight health check library for .NET and Azure Functions that runs async checks in parallel, preserves execution order and returns a clean JSON response with status, durations and optional error details.

Awesome Lists containing this project

README

          

# HealthCheckr

Lightweight async health checks for .NET and Azure Functions with ordered results and clean JSON output.

[![CI Build](https://github.com/kpol/HealthCheckr/actions/workflows/dotnetcore.yml/badge.svg)](https://github.com/kpol/HealthCheckr/actions/workflows/dotnetcore.yml)
[![Nuget](https://img.shields.io/nuget/v/HealthCheckr.svg?logo=nuget)](https://www.nuget.org/packages/HealthCheckr)

## Features

* Async health checks with support for `CancellationToken`
* Preserve registration order in JSON response
* Optional duration tracking per check
* Optional error reporting per check
* Configurable HTTP status codes for Healthy, Degraded, and Unhealthy states
* JSON output with enum status serialized as string
* Compatible with .NET 8+ (future .NET 10 support)

---

## Installation

Install via NuGet:

```bash
dotnet add package HealthCheckr
```

Or via the NuGet Package Manager:

```
PM> Install-Package HealthCheckr
```

---

## Usage

```csharp
using HealthCheckr;

var checker = new HealthChecker()
.AddCheck("Database", async ct => {
// perform your database check
return HealthStatus.Healthy;
}, "Checks database connectivity")
.AddCheck("Cache", async ct => {
// perform cache check
return HealthStatus.Degraded;
}, "Checks Redis cache availability");

var result = await checker.CheckAsync();

Console.WriteLine(result.ToJson());
```

### Example JSON Output

```json
{
"status": "Degraded",
"checks": [
{
"name": "Database",
"description": "Checks database connectivity",
"status": "Healthy",
"durationMs": 12
},
{
"name": "Cache",
"description": "Checks Redis cache availability",
"status": "Degraded",
"durationMs": 8
}
],
"totalDurationMs": 20,
"timestamp": "2026-01-19T11:15:23.123Z"
}
```

---

## Configuration

* `IncludeErrors` – Include exception details for failing checks.
* `IncludeDuration` – Include execution duration per check.
* `HealthyHttpStatusCode` / `DegradedHttpStatusCode` / `UnhealthyHttpStatusCode` – Customize HTTP response codes for overall status.

---

## Contributing

Contributions are welcome. Please open an issue or pull request on GitHub.

---

## License

© Kirill Polishchuk