< Summary

Information
Class: Elsa.Workflows.Runtime.HealthChecks.ElsaRuntimeHealthCheck
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaRuntimeHealthCheck.cs
Line coverage
90%
Covered lines: 20
Uncovered lines: 2
Coverable lines: 22
Total lines: 45
Line coverage: 90.9%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
CheckHealthAsync()100%2290.47%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/HealthChecks/ElsaRuntimeHealthCheck.cs

#LineLine coverage
 1using Elsa.Common;
 2using Microsoft.Extensions.Diagnostics.HealthChecks;
 3using Microsoft.Extensions.Logging;
 4
 5namespace Elsa.Workflows.Runtime.HealthChecks;
 6
 7/// <summary>
 8/// Reports whether the workflow runtime can create clients and is currently accepting new work.
 9/// </summary>
 310public class ElsaRuntimeHealthCheck(IWorkflowRuntime workflowRuntime, IQuiescenceSignal quiescenceSignal, ILogger<ElsaRu
 11{
 12    /// <inheritdoc />
 13    public async Task<HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToke
 14    {
 15        try
 16        {
 317            await workflowRuntime.CreateClientAsync(cancellationToken);
 18
 219            var state = quiescenceSignal.CurrentState;
 220            var data = new Dictionary<string, object>
 221            {
 222                ["category"] = "runtime",
 223                ["acceptingNewWork"] = state.IsAcceptingNewWork,
 224                ["reason"] = state.Reason.ToString(),
 225                ["activeExecutionCycles"] = quiescenceSignal.ActiveExecutionCycleCount
 226            };
 27
 228            return state.IsAcceptingNewWork
 229                ? HealthCheckResult.Healthy("Elsa workflow runtime is ready.", data)
 230                : HealthCheckResult.Degraded("Elsa workflow runtime is paused or draining.", data: data);
 31        }
 032        catch (OperationCanceledException) when (cancellationToken.IsCancellationRequested)
 33        {
 034            throw;
 35        }
 136        catch (Exception e) when (!e.IsFatal())
 37        {
 138            logger.LogWarning(e, "Elsa workflow runtime could not create a workflow client.");
 139            return HealthCheckResult.Unhealthy("Elsa workflow runtime could not create a workflow client.", data: new Di
 140            {
 141                ["category"] = "runtime"
 142            });
 43        }
 344    }
 45}