Address latest health check review feedback

Agent-Logs-Url: https://github.com/elsa-workflows/elsa-core/sessions/6a652ca4-f0c8-4284-938d-6de0eb7a2bea

Co-authored-by: sfmskywalker <938393+sfmskywalker@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-05-20 23:39:21 +00:00 committed by GitHub
parent 09641c1fab
commit 8c1618b5d4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 27 additions and 14 deletions

View file

@ -40,7 +40,7 @@ app.MapHealthChecks("/health/live", new()
app.MapHealthChecks("/health/ready", new()
{
Predicate = check => check.Tags.Contains(HealthCheckExtensions.ReadinessTag),
Predicate = check => check.Tags.Contains(HealthCheckExtensions.ElsaTag) && check.Tags.Contains(HealthCheckExtensions.ReadinessTag),
ResultStatusCodes =
{
[HealthStatus.Degraded] = StatusCodes.Status503ServiceUnavailable,

View file

@ -177,7 +177,7 @@ app.MapHealthChecks("/health/live", new()
});
app.MapHealthChecks("/health/ready", new()
{
Predicate = check => check.Tags.Contains(HealthCheckExtensions.ReadinessTag),
Predicate = check => check.Tags.Contains(HealthCheckExtensions.ElsaTag) && check.Tags.Contains(HealthCheckExtensions.ReadinessTag),
ResultStatusCodes =
{
[HealthStatus.Degraded] = StatusCodes.Status503ServiceUnavailable,
@ -186,12 +186,7 @@ app.MapHealthChecks("/health/ready", new()
});
app.MapHealthChecks("/", new()
{
Predicate = _ => false,
ResultStatusCodes =
{
[HealthStatus.Degraded] = StatusCodes.Status503ServiceUnavailable,
[HealthStatus.Unhealthy] = StatusCodes.Status503ServiceUnavailable
}
Predicate = _ => false
});
// Routing used for SignalR.

View file

@ -10,12 +10,17 @@ namespace Elsa.Extensions;
/// </summary>
public static class HealthCheckExtensions
{
/// <summary>
/// Tag applied to Elsa health checks.
/// </summary>
public const string ElsaTag = "elsa";
/// <summary>
/// Tag applied to Elsa readiness checks.
/// </summary>
public const string ReadinessTag = "readiness";
private static readonly string[] ReadinessTags = ["elsa", ReadinessTag];
private static readonly string[] ReadinessTags = [ElsaTag, ReadinessTag];
/// <summary>
/// Adds conservative Elsa-specific readiness probes for the workflow runtime and its core stores.

View file

@ -30,7 +30,7 @@ public class ElsaDistributedLockHealthCheck(
});
}
var lockName = $"elsa-health-check-{Environment.MachineName}-{Guid.NewGuid():N}";
var lockName = $"elsa-health-check-{Guid.NewGuid():N}";
await using var handle = await distributedLockProvider.TryAcquireLockAsync(lockName, options.Value.DistributedLockAcquisitionTimeout, cancellationToken);
if (handle == null)
{

View file

@ -20,10 +20,22 @@ public class ElsaWorkflowPersistenceHealthCheck(IServiceProvider serviceProvider
{
var probeResults = new List<ProbeResult>
{
await ProbeAsync("workflow-definitions", serviceProvider.GetService<IWorkflowDefinitionStore>(), async (store, ct) => await store.FindAsync(new WorkflowDefinitionFilter { Id = ProbeId }, ct)),
await ProbeAsync("workflow-instances", serviceProvider.GetService<IWorkflowInstanceStore>(), async (store, ct) => await store.CountAsync(new WorkflowInstanceFilter { Id = ProbeId }, ct)),
await ProbeAsync("triggers", serviceProvider.GetService<ITriggerStore>(), async (store, ct) => await store.FindAsync(new TriggerFilter { Id = ProbeId }, ct)),
await ProbeAsync("bookmark-queue", serviceProvider.GetService<IBookmarkQueueStore>(), async (store, ct) => await store.FindAsync(new BookmarkQueueFilter { Id = ProbeId }, ct))
await ProbeAsync("workflow-definitions", serviceProvider.GetService<IWorkflowDefinitionStore>(), async (store, ct) =>
{
await store.FindAsync(new WorkflowDefinitionFilter { Id = ProbeId }, ct);
}),
await ProbeAsync("workflow-instances", serviceProvider.GetService<IWorkflowInstanceStore>(), async (store, ct) =>
{
await store.CountAsync(new WorkflowInstanceFilter { Id = ProbeId }, ct);
}),
await ProbeAsync("triggers", serviceProvider.GetService<ITriggerStore>(), async (store, ct) =>
{
await store.FindAsync(new TriggerFilter { Id = ProbeId }, ct);
}),
await ProbeAsync("bookmark-queue", serviceProvider.GetService<IBookmarkQueueStore>(), async (store, ct) =>
{
await store.FindAsync(new BookmarkQueueFilter { Id = ProbeId }, ct);
})
};
var attemptedProbes = probeResults.Where(x => !x.Skipped).Select(x => x.StoreName).ToList();

View file

@ -50,6 +50,7 @@ public class ElsaDistributedLockHealthCheckTests
await sut.CheckHealthAsync(new HealthCheckContext());
Assert.Equal(2, lockNames.Count);
Assert.All(lockNames, x => Assert.DoesNotContain(Environment.MachineName, x, StringComparison.Ordinal));
Assert.NotEqual(lockNames[0], lockNames[1]);
}