Skip to content

Conversation

@jviau
Copy link
Contributor

@jviau jviau commented Oct 8, 2025

Issue describing the changes in this PR

resolves #11403

Pull request checklist

IMPORTANT: Currently, changes must be backported to the in-proc branch to be included in Core Tools and non-Flex deployments.

  • Backporting to the in-proc branch is not required
    • Otherwise: Link to backporting PR
  • My changes do not require documentation changes
    • Otherwise: Documentation issue linked to PR
  • My changes should not be added to the release notes for the next release
    • Otherwise: I've added my notes to release_notes.md
  • My changes do not need to be backported to a previous version
    • Otherwise: Backport tracked by issue/PR #issue_or_pr
  • My changes do not require diagnostic events changes
    • Otherwise: I have added/updated all related diagnostic events and their documentation (Documentation issue linked to PR)
  • I have added all required tests (Unit tests, E2E tests)

Additional information

This PR integrates IHealthCheck implementations from the ScriptHost scope. This is done by inserting a new DynamicHealthCheckService, which is effectively a wrapper around 2 health check services. (1) The existing WebJobs scoped health check service, and (2) the current active ScriptHost health check service (if one exists).

This approach is taken to ensure all health checks from the ScriptHost are ran in the correct service scope. An initial attempt was made to pull health check registrations from the active script host into the WebHost directly, but that will run them in the incorrect context and lead to wrong DI setup for them.

@jviau jviau requested a review from a team as a code owner October 8, 2025 18:17
Copilot AI review requested due to automatic review settings October 8, 2025 18:17
Copy link
Contributor

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 integrates health checks from the ScriptHost scope into the overall health check system by implementing a DynamicHealthCheckService that combines health checks from both WebHost and ScriptHost scopes. The implementation ensures that health checks run in their correct service scope contexts rather than being incorrectly executed in the WebHost scope.

Key changes:

  • Added a new Services property to IScriptHostManager interface to expose the ScriptHost service provider
  • Implemented DynamicHealthCheckService that wraps and coordinates two health check services (WebHost and ScriptHost)
  • Enhanced service provider extensions with a CreateInstance method to support dynamic service instantiation

Reviewed Changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
src/WebJobs.Script/Host/IScriptHostManager.cs Added Services property to expose ScriptHost service provider
src/WebJobs.Script/Extensions/IServiceProviderExtensions.cs Added CreateInstance method for dynamic service instantiation
src/WebJobs.Script/Diagnostics/HealthChecks/HealthCheckExtensions.cs Added UseDynamicHealthCheckService extension method
src/WebJobs.Script/Diagnostics/HealthChecks/DynamicHealthCheckService.cs New service that coordinates WebHost and ScriptHost health checks
src/WebJobs.Script.WebHost/DependencyInjection/ServiceProviderExtensions.cs Updated child container ignored types to include health check services
test/WebJobs.Script.Tests/Diagnostics/HealthChecks/DynamicHealthCheckServiceTests.cs Comprehensive test suite for the new DynamicHealthCheckService
test/WebJobs.Script.Tests/Diagnostics/HealthChecks/HealthCheckExtensionsTests.cs Tests for the new UseDynamicHealthCheckService extension
test/WebJobs.Script.Tests/Extensions/ServiceProviderExtensionsTests.cs Tests for the new CreateInstance extension method
test/WebJobs.Script.Tests/Metrics/LinuxContainerLegionMetricsPublisherTests.cs Updated test mock to implement new Services property
test/WebJobs.Script.Tests.Shared/TestHelpers.cs Updated test helper to implement new Services property

@jviau jviau merged commit 9614ca4 into dev Oct 15, 2025
9 checks passed
@jviau jviau deleted the u/jviau/script-host-health-checks branch October 15, 2025 16:45
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.

[HealthChecks] Integration IHealthCheck implementations from active ScriptHost into health checks.

4 participants