Pdsr.HealthChecks
2.3.0
dotnet add package Pdsr.HealthChecks --version 2.3.0
NuGet\Install-Package Pdsr.HealthChecks -Version 2.3.0
<PackageReference Include="Pdsr.HealthChecks" Version="2.3.0" />
<PackageVersion Include="Pdsr.HealthChecks" Version="2.3.0" />
<PackageReference Include="Pdsr.HealthChecks" />
paket add Pdsr.HealthChecks --version 2.3.0
#r "nuget: Pdsr.HealthChecks, 2.3.0"
#:package Pdsr.HealthChecks@2.3.0
#addin nuget:?package=Pdsr.HealthChecks&version=2.3.0
#tool nuget:?package=Pdsr.HealthChecks&version=2.3.0
Pdsr HealthChecks Libraries
Contains HealthChecks for OpenId-Connect, RedisCacheManager, Postgres, and RabbitMQ.
Getting Started
Health checks need to register in the DI container.
Redis Healthcheck
In the minimal API, use builder.Services to add the extension method, AddRedisCacheManager to IHealthChecksBuilder.
var degradedThreshold = 50; // in milliseconds, response time higher than 50 will be considered degraded
var unhealthyThreshold = 100; // in milliseconds, response time higher than 100 will be considered unhealthy
builder.Services.AddHealthChecks()
.AddRedisCacheManager(degradedThreshold,unhealthyThreshold);
Memory HealthCheck
You can define a memory usage limit for the MemoryHealthCheck
In the minimal API, use builder.Services to add the extension method, AddMemoryHealthCheck to IHealthChecksBuilder
builder.Services.AddHealthChecks()
.AddMemoryHealthCheck(
degradedThreshold: 50 * 1024L * 1024L, // shows degraded at this 50 MB
unhealthyThreshold: 100 * 2048L * 2048L, // threshold to show failureStatus (unhealthy), 100MB
failureStatus: HealthStatus.Unhealthy, // default failure status is HealthStatus.Unhealthy
tags: new string[] { "memory", "ram" }); // optional tags
Health Publisher
The interface ISystemHealth and the abstract class SystemHealthBase are available to be used as publisher.
you need to inherit from SystemHealthBase:
public class MyHealthStatus : SystemHealthBase
{
// some custom properties
}
Register in DI container
builder.Services.RegisterReadinessPublisher<MyHealthStatus>();
The instance of MyHealthStatus is available through injection.
public class SomeService : ISomeService
{
private readonly MySystemHealth _mySystemHealth;
public SomeService(MySystemHealth mySystemHealth)
{
_mySystemHealth = _mySystemHealth;
}
public void SomeMethod()
{
var health = _mySystemHealth.HealthReport;
// do whatever you like with that health status.
}
}
Samples
Refer to the samples folder.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 is compatible. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. 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. |
-
net6.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.0)
-
net7.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.0)
-
net8.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 8.0.2)
- Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (>= 8.0.2)
- Microsoft.Extensions.Http (>= 8.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Pdsr.HealthChecks:
| Package | Downloads |
|---|---|
|
Pdsr.HealthChecks.Npgsql
Npgsql Postgres Healthchecks |
|
|
Pdsr.HealthChecks.Redis
Redis Cache Manager HealthCheck system. |
GitHub repositories
This package is not used by any popular GitHub repositories.