-
Notifications
You must be signed in to change notification settings - Fork 171
Fix scoped ASP.NET health checks, correct AddHealthContributor docs #1636
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
a193273 to
1924924
Compare
Summary - All Code Coverage (ubuntu-latest)
|
…thContributor documentation
1924924 to
6038063
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR fixes an issue with scoped ASP.NET health checks by ensuring that a service scope is created for each health check execution, matching ASP.NET's HealthCheckService behavior. It also corrects documentation that incorrectly stated health contributors were registered as scoped services when they are actually singletons.
Key changes:
- Modified
HealthAggregatorto create a service scope for each Microsoft health check execution, enabling support for scoped dependencies - Corrected XML documentation comments in
EndpointServiceCollectionExtensionsto accurately reflect that health contributors are registered as singleton services - Enhanced test infrastructure to validate service scopes and added a comprehensive test for scoped health checks using Entity Framework Core
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| src/Management/test/Endpoint.Test/Steeltoe.Management.Endpoint.Test.csproj | Added Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore package dependency to support testing scoped health checks |
| src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs | Added new test method and TestDbContext class to verify scoped ASP.NET health checks work correctly |
| src/Management/src/Endpoint/Actuators/Health/EndpointServiceCollectionExtensions.cs | Fixed documentation comments to correctly state that health contributors are registered as singleton services |
| src/Common/test/TestResources/TestWebApplicationBuilderFactory.cs | Added service provider configuration for the Host to enable scope validation in tests |
| src/Common/test/TestResources/TestHostBuilderFactory.cs | Added service provider configuration for web host builder to enable scope validation in tests |
| src/Common/src/Common/HealthChecks/HealthAggregator.cs | Implemented scope creation for each Microsoft health check to support scoped services like EF Core DbContext |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/Management/test/Endpoint.Test/Actuators/Health/HealthAggregationTest.cs
Outdated
Show resolved
Hide resolved
…gationTest.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
|



Description
Fixes #1635.
Quality checklist
If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.