Add Expanded Health Check Capability#15019
Conversation
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 15019Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 15019" |
@dotnet-policy-service agree company="Microsoft" |
adamint
left a comment
There was a problem hiding this comment.
It should go through API review, but I really like this change and only have minimal comments
There was a problem hiding this comment.
Pull request overview
Adds support for “expanded” HTTP health checks in Aspire by introducing an Aspire-formatted health response writer for services and updating the AppHost-side HTTP health check to parse and surface multiple sub-checks in the dashboard.
Changes:
- Introduces new
Aspire.HealthCheckspackage withAspireHealthCheckResponseWriterto emit an Aspire-parsable JSON health payload. - Updates
WithHttpHealthCheckto use a customAspireHttpHealthCheckthat can parse the Aspire health JSON format and attach sub-entries for dashboard expansion. - Expands host-side health report merging to fan out sub-entries, and adds new unit/functional tests plus test/playground projects to validate the behavior.
Reviewed changes
Copilot reviewed 26 out of 26 changed files in this pull request and generated 6 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/testproject/TestProject.HealthCheckService/TestProject.HealthCheckService.csproj | Adds a new test service that references Aspire.HealthChecks. |
| tests/testproject/TestProject.HealthCheckService/Properties/launchSettings.json | Launch profile for the new health check test service. |
| tests/testproject/TestProject.HealthCheckService/Program.cs | Implements multiple health checks and maps /health using the Aspire response writer. |
| tests/testproject/TestProject.AppHost/TestProject.AppHost.csproj | References the new health check test service project. |
| tests/Shared/RepoTesting/Directory.Packages.Helix.props | Adds package version pinning for Aspire.HealthChecks in Helix testing. |
| tests/Aspire.Hosting.Tests/Utils/TestDistributedApplicationBuilder.cs | Removes default HTTP client resilience configuration from the test builder. |
| tests/Aspire.HealthChecks.Tests/AspireHttpHealthCheckUnitTests.cs | Adds unit coverage for parsing Aspire-format health JSON into expanded sub-entries. |
| tests/Aspire.HealthChecks.Tests/AspireHealthCheckFunctionalTests.cs | Adds functional tests validating Aspire health JSON output and dashboard expansion behavior. |
| tests/Aspire.HealthChecks.Tests/Aspire.HealthChecks.Tests.csproj | Introduces a dedicated test project for the expanded health checks feature. |
| src/Aspire.Hosting/ResourceBuilderExtensions.cs | Reworks WithHttpHealthCheck to register a custom health check implementation. |
| src/Aspire.Hosting/Health/ResourceHealthCheckService.cs | Expands health report snapshots when a result contains multiple sub-entries. |
| src/Aspire.Hosting/Health/HealthCheckConstants.cs | Defines internal keys/property names used for expanded health check data exchange and parsing. |
| src/Aspire.Hosting/Health/AspireHttpHealthCheck.cs | Adds the HTTP health check implementation that parses Aspire-format health responses. |
| src/Aspire.Hosting/Aspire.Hosting.csproj | Grants internals access to the new Aspire.HealthChecks.Tests assembly. |
| src/Aspire.HealthChecks/README.md | Adds package README describing how to enable expanded health responses. |
| src/Aspire.HealthChecks/AspireHealthCheckResponseWriter.cs | Adds the response writer that emits Aspire-format JSON health results. |
| src/Aspire.HealthChecks/Aspire.HealthChecks.csproj | Introduces the new Aspire.HealthChecks packable library project. |
| playground/HealthChecks/HealthChecksSandbox.PlainHealthService/Properties/launchSettings.json | Adds launch settings for a playground “plain” health service. |
| playground/HealthChecks/HealthChecksSandbox.PlainHealthService/Program.cs | Adds a playground service using default health endpoint behavior (no Aspire writer). |
| playground/HealthChecks/HealthChecksSandbox.PlainHealthService/HealthChecksSandbox.PlainHealthService.csproj | Adds the playground “plain” health service project. |
| playground/HealthChecks/HealthChecksSandbox.ExpandedHealthService/Properties/launchSettings.json | Adds launch settings for a playground “expanded” health service. |
| playground/HealthChecks/HealthChecksSandbox.ExpandedHealthService/Program.cs | Adds a playground service that uses AspireHealthCheckResponseWriter. |
| playground/HealthChecks/HealthChecksSandbox.ExpandedHealthService/HealthChecksSandbox.ExpandedHealthService.csproj | Adds the playground “expanded” health service project and references Aspire.HealthChecks. |
| playground/HealthChecks/HealthChecksSandbox.AppHost/Program.cs | Adds playground scenarios demonstrating keyed, expanded HTTP, and plain HTTP health checks. |
| playground/HealthChecks/HealthChecksSandbox.AppHost/HealthChecksSandbox.AppHost.csproj | References Aspire.HealthChecks and the new playground health service projects. |
| Aspire.slnx | Adds the new library, tests, and playground/testproject projects to the solution. |
You can also share your feedback on Copilot code review. Take the survey.
tests/Aspire.HealthChecks.Tests/AspireHealthCheckFunctionalTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
| var status = HealthStatus.Unhealthy; | ||
| if (entryValue.TryGetProperty(HealthCheckConstants.JsonProperties.Status, out var entryStatusElement)) | ||
| { | ||
| status = Enum.Parse<HealthStatus>(entryStatusElement.GetString()!, ignoreCase: true); |
There was a problem hiding this comment.
be defensive about type, skip if not string
Description
Please include a summary of the changes and the related issue. Please also include relevant motivation and context. List any dependencies that are required for this change.
Fixes # (issue)
Checklist
<remarks />and<code />elements on your triple slash comments?aspire.devissue: