< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: Microsoft.Extensions.DependencyInjection.AsyncResponseHealthCheckExtensions
Assembly: AsyncResponse.Core
File(s): /_/src/AsyncResponse.Core/AsyncResponseHealthCheckExtensions.cs
Line coverage
100%
Covered lines: 9
Uncovered lines: 0
Coverable lines: 9
Total lines: 37
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddAsyncResponseRecoveryCheck(...)100%11100%

File(s)

/_/src/AsyncResponse.Core/AsyncResponseHealthCheckExtensions.cs

#LineLine coverage
 1using AsyncResponse;
 2using Microsoft.Extensions.DependencyInjection.Extensions;
 3using Microsoft.Extensions.Diagnostics.HealthChecks;
 4
 5namespace Microsoft.Extensions.DependencyInjection;
 6
 7/// <summary>
 8/// Health-check registration for AsyncResponse. This is the one feature deliberately added on the
 9/// health-checks pipeline rather than the fluent <c>AddAsyncResponse()</c> builder, because it
 10/// belongs to <c>AddHealthChecks()</c>.
 11/// </summary>
 12public static class AsyncResponseHealthCheckExtensions
 13{
 14    /// <summary>
 15    /// Adds the <see cref="AsyncResponseRecoveryHealthCheck"/> to the health-check pipeline. It
 16    /// reads the watchdog's cached snapshot (probes never touch the recovery store) and reports at
 17    /// most <c>Degraded</c> — stale flows are an operator signal, not process ill-health, so keep
 18    /// <c>Degraded</c> mapped to HTTP 200 on readiness endpoints (the ASP.NET Core default). The
 19    /// watchdog itself runs by default once <c>AddAsyncResponse()</c> is registered.
 20    /// </summary>
 21    public static IHealthChecksBuilder AddAsyncResponseRecoveryCheck(
 22        this IHealthChecksBuilder builder,
 23        string name = "async-response-recovery",
 24        IEnumerable<string>? tags = null)
 25    {
 1026        builder.Services.TryAddSingleton<AsyncResponseWatchdogState>();
 1027        builder.Add(new HealthCheckRegistration(
 1028            name,
 1029            // Pass the engine clock: the watchdog stamps ScanCompletedUtc from it, and the staleness
 1030            // math is meaningless (negative or permanently tripped) if the two sides read different clocks.
 331            provider => new AsyncResponseRecoveryHealthCheck(provider.GetRequiredService<AsyncResponseWatchdogState>(), 
 1032            failureStatus: HealthStatus.Degraded,
 1033            tags));
 34
 1035        return builder;
 36    }
 37}