< Summary

Information
Class: Gateway.Probes
Assembly: Gateway
File(s): /home/runner/work/dotnet-microservice/dotnet-microservice/Gateway/GlobalConfigurations/Probes.cs
Tag: 34_11887803474
Line coverage
0%
Covered lines: 0
Uncovered lines: 27
Coverable lines: 27
Total lines: 46
Line coverage: 0%
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

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
UseProbes(...)100%210%

File(s)

/home/runner/work/dotnet-microservice/dotnet-microservice/Gateway/GlobalConfigurations/Probes.cs

#LineLine coverage
 1using HealthChecks.UI.Client;
 2using Microsoft.AspNetCore.Diagnostics.HealthChecks;
 3using Microsoft.Extensions.Diagnostics.HealthChecks;
 4
 5namespace Gateway;
 6
 7public static class Probes
 8{
 9    private const string LivenessProbe = $"/{LivenessTag}";
 10    private const string ReadinessProbe = $"/{ReadinessTag}";
 11    private const string LivenessTag = "alive";
 12    private const string ReadinessTag = "health";
 13
 14    public static WebApplication UseProbes(this WebApplication app)
 15    {
 016        app.MapHealthChecks(
 017            ReadinessProbe,
 018            new HealthCheckOptions
 019            {
 020                Predicate = (x) => x.Tags.Contains(ReadinessTag, StringComparer.OrdinalIgnoreCase),
 021                ResultStatusCodes =
 022                {
 023                    [HealthStatus.Healthy] = StatusCodes.Status200OK,
 024                    [HealthStatus.Degraded] = StatusCodes.Status200OK,
 025                    [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
 026                }
 027            }
 028        );
 29
 030        app.MapHealthChecks(
 031            LivenessProbe,
 032            new HealthCheckOptions
 033            {
 034                Predicate = (x) => x.Tags.Contains(LivenessTag, StringComparer.OrdinalIgnoreCase),
 035                ResultStatusCodes =
 036                {
 037                    [HealthStatus.Healthy] = StatusCodes.Status200OK,
 038                    [HealthStatus.Degraded] = StatusCodes.Status200OK,
 039                    [HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
 040                }
 041            }
 042        );
 43
 044        return app;
 45    }
 46}