Skip to content

Add Wolverine.HealthChecks for ASP.NET Core IHealthCheck integration (CritterWatch#73)#2687

Merged
jeremydmiller merged 1 commit intomainfrom
feat/cw73-healthchecks
May 7, 2026
Merged

Add Wolverine.HealthChecks for ASP.NET Core IHealthCheck integration (CritterWatch#73)#2687
jeremydmiller merged 1 commit intomainfrom
feat/cw73-healthchecks

Conversation

@jeremydmiller
Copy link
Copy Markdown
Member

Summary

Adds a new thin extension package, WolverineFx.HealthChecks, that plugs Wolverine into the standard ASP.NET Core
health-check pipeline. Two checks ship in the box:

  • WolverineBusHealthCheck — Healthy when the runtime has finished starting and the runtime cancellation token has not been signalled. HealthCheckResult.Data exposes serviceName, uniqueNodeId, started, cancellationRequested.
  • WolverineListenerHealthCheck — Walks IWolverineRuntime.Endpoints.ActiveListeners() and reports:
    • Healthy — all listeners Accepting
    • Degraded — any listener TooBusy or GloballyLatched
    • Unhealthy — all listeners Stopped
    • Per-listener counts and a URI-keyed status map go into HealthCheckResult.Data so dashboards can render detail without a second probe.

API shape

Conventional IHealthChecksBuilder extensions (mirrors Microsoft.Extensions.Diagnostics.HealthChecks + community packages):

builder.Services.AddHealthChecks()
    .AddWolverine(tags: new[] { "live", "ready" })
    .AddWolverineListeners(
        filter: agent => agent.Uri.Scheme == "rabbitmq",
        tags: new[] { "ready" });

Both extensions accept name / failureStatus / tags / timeout. AddWolverineListeners also takes an optional Func<IListeningAgent, bool> filter for scoping a check to a subset of listeners — useful when you want a separate readiness probe per transport.

Out of scope

Per-broker connectivity health checks (RabbitMQ, Azure Service Bus, Kafka, etc.) are deliberately not part of this PR — they live with each transport package and will be addressed by transport-specific helpers (tracked separately under CritterWatch#70).

Implementation notes

  • New project lives at src/Wolverine.HealthChecks/. It depends only on Wolverine core + Microsoft.Extensions.Diagnostics.HealthChecks(.Abstractions). Microsoft.Extensions.* health-check packages are real dependencies, so we did not fold these checks into Wolverine.Http where they would weigh down every Wolverine.Http consumer.
  • Versions are centrally managed in Directory.Packages.props against the existing TFM-conditional Microsoft.Extensions.* version ranges.
  • The new project + tests project are added to wolverine.slnx. wolverine_slim.slnx is unchanged.
  • Docs page added at docs/guide/health-checks.md and wired into the VitePress sidebar next to the existing Diagnostics page.

Test plan

  • Unit tests against an IWolverineRuntime substitute cover started / not-started / cancellation-requested for the bus check, and Healthy / Degraded / Unhealthy / scope-filter cases for the listener check (NSubstitute, already a dev dependency).
  • Integration test boots an in-process Microsoft.AspNetCore.TestHost host with .AddWolverine().AddWolverineListeners() and asserts /health, /health/live, /health/ready all return 200.
  • dotnet build wolverine.slnx — clean (0 errors).
  • dotnet test src/Wolverine.HealthChecks.Tests/Wolverine.HealthChecks.Tests.csproj — 13/13 passing.

Refs CritterWatch#73.

Introduces a new thin extension package WolverineFx.HealthChecks that
plugs Wolverine into the standard Microsoft.Extensions.Diagnostics
health-check pipeline.

API:
  services.AddHealthChecks()
          .AddWolverine()           // bus health: started + not cancelling
          .AddWolverineListeners(); // listener health: Accepting/TooBusy/...

Both extensions accept the conventional name/tags/failureStatus/timeout
parameters so operators can split Kubernetes liveness vs. readiness
probes and alias checks however they like. AddWolverineListeners also
takes an optional Func<IListeningAgent,bool> filter for scoping a check
to a subset of listeners (e.g. by URI scheme).

Listener status mapping:
  - all Accepting              -> Healthy
  - any TooBusy/GloballyLatched -> Degraded
  - all Stopped                 -> Unhealthy

Per-listener counts and a URI-keyed status map are exposed via
HealthCheckResult.Data so dashboards can render detail without a
second probe.

Per-broker connectivity checks (RabbitMQ / Azure Service Bus / etc.)
are intentionally out of scope here.

Includes 13 tests (NSubstitute unit tests + an in-process TestServer
integration test that exercises the registered checks via /health).

Adds a docs page under docs/guide/health-checks.md and wires it into
the sidebar.

Refs CritterWatch#73.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant