Health monitoring and diagnostics extension for WorkflowForge providing comprehensive health checks, dependency monitoring, and system status reporting for production workflows.
$ dotnet add package WorkflowForge.Extensions.Observability.HealthChecksHealth check integration extension for WorkflowForge compatible with Microsoft.Extensions.Diagnostics.HealthChecks.
This extension has ZERO external dependencies. This means:
Interface-only: Implements IHealthCheck interface without requiring the full Microsoft package.
dotnet add package WorkflowForge.Extensions.Observability.HealthChecks
Requires: .NET Standard 2.0 or later
using WorkflowForge.Extensions.Observability.HealthChecks;
// Configure health checks
var healthCheck = new WorkflowHealthCheck(
timeProvider: new SystemTimeProvider(),
unhealthyThresholdSeconds: 30);
// Register workflow execution
smith.WorkflowStarted += (s, e) => healthCheck.RecordWorkflowExecution();
smith.WorkflowCompleted += (s, e) => healthCheck.RecordWorkflowExecution();
// Check health
var healthStatus = await healthCheck.CheckHealthAsync(new HealthCheckContext());
if (healthStatus.Status == HealthStatus.Unhealthy)
{
logger.LogWarning("WorkflowForge health check failed: {Description}",
healthStatus.Description);
}
ISystemTimeProvider for testability// Startup.cs or Program.cs
services.AddSingleton<ISystemTimeProvider, SystemTimeProvider>();
services.AddSingleton<WorkflowHealthCheck>();
services.AddHealthChecks()
.AddCheck<WorkflowHealthCheck>("workflow_health");
app.MapHealthChecks("/health");
var healthCheck = new WorkflowHealthCheck(
timeProvider: serviceProvider.GetRequiredService<ISystemTimeProvider>(),
unhealthyThresholdSeconds: 30);
// Subscribe to events
smith.WorkflowStarted += (s, e) => healthCheck.RecordWorkflowExecution();
smith.WorkflowCompleted += (s, e) => healthCheck.RecordWorkflowExecution();
See Configuration Guide for complete options.
public class CustomWorkflowHealthCheck : IHealthCheck
{
private readonly IWorkflowSmith _smith;
private DateTime _lastExecution;
public async Task<HealthCheckResult> CheckHealthAsync(
HealthCheckContext context,
CancellationToken cancellationToken = default)
{
var timeSinceLastExecution = DateTime.UtcNow - _lastExecution;
if (timeSinceLastExecution > TimeSpan.FromMinutes(5))
{
return HealthCheckResult.Unhealthy(
$"No workflow execution in {timeSinceLastExecution.TotalMinutes:F1} minutes");
}
return HealthCheckResult.Healthy("Workflows executing normally");
}
}
Health checks can be monitored via:
/health endpoint