Skip to content

Conversation

@bart-vmware
Copy link
Member

Description

Fixes #1635.

Quality checklist

  • Your code complies with our Coding Style.
  • You've updated unit and/or integration tests for your change, where applicable.
  • You've updated documentation for your change, where applicable.
    If your change affects other repositories, such as Documentation, Samples and/or MainSite, add linked PRs here.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.
  • You've added required license files and/or file headers (explaining where the code came from with proper attribution), where code is copied from StackOverflow, a blog, or OSS.

@bart-vmware bart-vmware force-pushed the fix-aspnet-scoped-health-checks branch from a193273 to 1924924 Compare December 19, 2025 15:32
@bart-vmware bart-vmware changed the title Create a service scope for each ASP.NET health check, correct AddHealthContributor documentation Fix scoped ASP.NET health checks, correct AddHealthContributor docs Dec 19, 2025
@github-actions
Copy link
Contributor

Summary - All Code Coverage (ubuntu-latest)

Line coverage Branch coverage

Assembly Line coverage Branch coverage
Steeltoe.Bootstrap.AutoConfiguration 97.4% 100%
Steeltoe.Common 84.3% 78.6%
Steeltoe.Common.Certificates 96.2% 85.5%
Steeltoe.Common.Hosting 84% 70%
Steeltoe.Common.Http 100% 85.2%
Steeltoe.Common.Logging 81.1% 56.2%
Steeltoe.Common.Net 64.5% 66.6%
Steeltoe.Configuration.Abstractions 98.5% 91.1%
Steeltoe.Configuration.CloudFoundry 99.1% 91.8%
Steeltoe.Configuration.ConfigServer 97.2% 91.6%
Steeltoe.Configuration.Encryption 97.6% 92.4%
Steeltoe.Configuration.Kubernetes.ServiceBindings 95.1% 89.3%
Steeltoe.Configuration.Placeholder 93.8% 84.7%
Steeltoe.Configuration.RandomValue 93.2% 90%
Steeltoe.Configuration.SpringBoot 98.3% 95%
Steeltoe.Connectors 93.9% 89.8%
Steeltoe.Connectors.EntityFrameworkCore 81.5% 75%
Steeltoe.Discovery.Configuration 92.3% 100%
Steeltoe.Discovery.Consul 97.6% 96.1%
Steeltoe.Discovery.Eureka 91.8% 85.2%
Steeltoe.Discovery.HttpClients 94.2% 95.4%
Steeltoe.Logging.Abstractions 99.4% 96.9%
Steeltoe.Logging.DynamicConsole 100% 95.4%
Steeltoe.Logging.DynamicSerilog 99.1% 95.4%
Steeltoe.Management.Abstractions 100% 100%
Steeltoe.Management.Endpoint 95.5% 89.1%
Steeltoe.Management.Prometheus 95.9% 91.6%
Steeltoe.Management.Tasks 100% ****
Steeltoe.Management.Tracing 100% 75%
Steeltoe.Security.Authentication.JwtBearer 100% 100%
Steeltoe.Security.Authentication.OpenIdConnect 73.8% 59%
Steeltoe.Security.Authorization.Certificate 96.3% 75%
Steeltoe.Security.DataProtection.Redis 100% ****

@bart-vmware bart-vmware force-pushed the fix-aspnet-scoped-health-checks branch from 1924924 to 6038063 Compare December 19, 2025 15:58
@bart-vmware bart-vmware marked this pull request as ready for review December 19, 2025 15:58
@bart-vmware bart-vmware added Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line labels Dec 19, 2025
@bart-vmware bart-vmware added this to the 4.1.0 milestone Dec 19, 2025
Copy link

Copilot AI left a 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 HealthAggregator to create a service scope for each Microsoft health check execution, enabling support for scoped dependencies
  • Corrected XML documentation comments in EndpointServiceCollectionExtensions to 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.

…gationTest.cs

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@sonarqubecloud
Copy link

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

Labels

Component/Management Issues related to Steeltoe Management (actuators) ReleaseLine/4.x Identified as a feature/fix for the 4.x release line

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Health actuator cannot handle health checks depending on scoped services

2 participants