AddTraxSchedulerLiveness

Registers an ASP.NET Core health check that reports unhealthy when the JobDispatcher has not completed a polling cycle within a threshold. Unlike a process or port probe, this catches a scheduler that is up but dispatching nothing. A cycle still running counts from when it began, and the check reports healthy while dispatch is paused or when the host runs no JobDispatcher (InMemory); see Health & Liveness.

Signature

public static IHealthChecksBuilder AddTraxSchedulerLiveness(
    this IHealthChecksBuilder builder,
    string name = "scheduler-liveness",
    TimeSpan? threshold = null,
    HealthStatus failureStatus = HealthStatus.Unhealthy,
    IEnumerable<string>? tags = null
)

Parameters

ParameterTypeRequiredDefaultDescription
namestringNoscheduler-livenessThe health check name
thresholdTimeSpan?NonullStaleness threshold. When null, uses SchedulerConfiguration.SchedulerLivenessThreshold, falling back to max(JobDispatcherPollingInterval * 10, 30s)
failureStatusHealthStatusNoUnhealthyThe status reported when stale
tagsIEnumerable<string>?NonullTags for filtering health checks

Returns

IHealthChecksBuilder, for continued fluent chaining.

Example

builder.Services.AddHealthChecks().AddTraxSchedulerLiveness();
 
var app = builder.Build();
app.MapHealthChecks("/health");

With a custom threshold and a degraded (non-failing) status:

builder.Services
    .AddHealthChecks()
    .AddTraxSchedulerLiveness(
        threshold: TimeSpan.FromSeconds(20),
        failureStatus: HealthStatus.Degraded,
        tags: ["scheduler"]
    );

Remarks

  • The scheduler registers the underlying ISchedulerLivenessMonitor automatically. The JobDispatcher's polling loop stamps it after each successful cycle, including empty no-op polls. The interface only exposes StartedAt and LastDispatchCompletedAt; recording a cycle is internal to the dispatcher.
  • Before the first cycle completes, the check measures from scheduler startup, so a cold start is healthy within the grace window but a scheduler that never dispatches still trips.
  • The check writes lastDispatchCompletedAt, ageSeconds, and thresholdSeconds into its result data.
  • The threshold can also be set on the scheduler builder with .SchedulerLivenessThreshold(TimeSpan); the threshold argument here overrides it.

See Also