-
Notifications
You must be signed in to change notification settings - Fork 464
[HealthChecks] Add health check middleware #11173
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: dev
Are you sure you want to change the base?
Conversation
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckResponseWriter.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckResponseWriter.cs
Outdated
Show resolved
Hide resolved
5ab9426
to
c6fff79
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.
lgtm, minor comments. deps json looks good, I don't see any major version bumps
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 adds health check middleware infrastructure to support health check endpoints with two main features: long polling capabilities and configurable response formats. It removes the unused ApiErrorModel
class and introduces a new ARM-compliant ErrorResponse
model.
- Adds
HealthCheckWaitMiddleware
to enable HTTP long polling via?wait={seconds}
query parameter - Adds
HealthCheckResponseWriter
to handle both minimal and expanded health check responses via?expand={true/false}
- Replaces deprecated
ApiErrorModel
with ARM-compliantErrorResponse
model
Reviewed Changes
Copilot reviewed 20 out of 20 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
HealthCheckWaitMiddleware.cs | Implements long polling for health checks with wait parameter support |
HealthCheckResponseWriter.cs | Handles response formatting with minimal/expanded modes |
ErrorResponse.cs | New ARM-compliant error model replacing deprecated ApiErrorModel |
ScriptHostManagerExtensions.cs | Renames method to DelayUntilHostReadyAsync for consistency |
Test files | Comprehensive unit tests for new middleware and response writer |
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckWaitMiddleware.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckResponseWriter.cs
Show resolved
Hide resolved
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckWaitMiddleware.cs
Outdated
Show resolved
Hide resolved
src/WebJobs.Script.WebHost/Diagnostics/HealthChecks/HealthCheckWaitMiddleware.cs
Outdated
Show resolved
Hide resolved
public static class JsonSerializerOptionsProvider | ||
{ | ||
/// <summary> | ||
/// Gets the default JSON serializer options used across the functions host. |
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.
nit: Not sure we should mention "used across the functions host". I prefer something along the line of "Shared Json serializer with the following settings: 1) Trailing commas allowed, 2) camel casing ...."
using System.Text.Json.Nodes; | ||
using System.Threading.Tasks; | ||
using FluentAssertions; | ||
using HealthChecks.UI.Client; |
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.
Remove unnecessary usings.
Issue describing the changes in this PR
Part of #11010, #11171
Pull request checklist
IMPORTANT: Currently, changes must be backported to the
in-proc
branch to be included in Core Tools and non-Flex deployments.in-proc
branch is not requiredrelease_notes.md
Additional information
Adds supporting files for the eventual addition of a health check endpoint. The added files do two primary things:
HealthCheckWaitMiddleware.cs
-- this file enables HTTP long polling of health probes by adding a?wait={timeInSeconds}
query string to the health check calls.HealthCheckResponseWriter
-- this files writes the HTTP responses for health checks. It has 2 modes, a minimal or an expanded response.?expand={true/false}
. Default isfalse
if not included.This PR also removes
ApiErrorModel
(it is unused) and introducesErrorResponse
, which is modeled after the ARM recommended error structure.