-
Notifications
You must be signed in to change notification settings - Fork 466
[HealthChecks] Add TelemetryHealthCheckPublisher #11178
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/Diagnostics/HealthChecks/HealthCheckMetrics.cs
Outdated
Show resolved
Hide resolved
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 a new TelemetryHealthCheckPublisher
that publishes health check results as telemetry data (logs and metrics), along with supporting infrastructure for object pooling. The implementation enables health check monitoring through structured telemetry with configurable filtering by tags.
- Introduces
TelemetryHealthCheckPublisher
with telemetry output for health checks (logs for unhealthy states, metrics for all states) - Adds object pooling infrastructure with
PoolFactory
,PoolRental<T>
, and extensions for efficient memory management - Updates test dependencies from FluentAssertions to AwesomeAssertions across multiple test files
Reviewed Changes
Copilot reviewed 23 out of 23 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/WebJobs.Script/Diagnostics/HealthChecks/TelemetryHealthCheckPublisher.cs | Core publisher implementation with logging and metrics recording |
src/WebJobs.Script/Diagnostics/HealthChecks/HealthCheckMetrics.cs | Metrics infrastructure for health check telemetry |
src/WebJobs.Script/Diagnostics/HealthChecks/HealthCheckExtensions.cs | Extension methods for registering publishers and filtering reports |
src/WebJobs.Script/Pools/*.cs | Object pooling infrastructure for performance optimization |
test/WebJobs.Script.Tests/Diagnostics/HealthChecks/TelemetryHealthCheckPublisherTests.cs | Comprehensive unit tests for the publisher |
eng/build/Engineering.props | Language version update to preview |
Multiple test files | Dependency updates and test assertion library migration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
src/WebJobs.Script/Diagnostics/HealthChecks/TelemetryHealthCheckPublisher.cs
Outdated
Show resolved
Hide resolved
@@ -49,6 +49,7 @@ | |||
<PackageReference Include="Microsoft.CodeAnalysis.CSharp.Scripting" Version="3.3.1" /> | |||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="8.0.0" /> | |||
<PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" Version="8.0.0" /> | |||
<PackageReference Include="Microsoft.Extensions.Telemetry.Abstractions" Version="8.10.0" /> |
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.
Did you run into any issues with the 9.8.0?
public static Action Act(Action act) => act; | ||
|
||
/// <summary> | ||
/// Helper method to inline an action delegate. |
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.
Did you mean func
delegate?
Issue describing the changes in this PR
Part of #11010
Resolves #11170
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 an
IHealthCheckPublisher
which publishes health checks as telemetry.azure.functions.health_check.reports
[1]: Represents the health as a double, ranging from 0 to 1. 1 = healthy, 0.5 = degraded, 0 = unhealthy. By keeping this between 0 and 1, we open the door to a percentage based health calculation.
azure.functions.health_check.tag
<empty_string>
[1],azure.functions.liveness
,azure.functions.readiness
[1]: Empty string represents all health checks being included for this metric
azure.functions.health_check.unhealthy_checks
[1]: Represents the health as a double, ranging from 0 to 1. 1 = healthy, 0.5 = degraded, 0 = unhealthy. By keeping this between 0 and 1, we open the door to a percentage based health calculation.
azure.functions.health_check.tag
<empty_string>
[1],azure.functions.liveness
,azure.functions.readiness
azure.functions.health_check.name
azure.functions.script_host.lifecycle
,azure.functions.web_host.lifecycle
,azure.functions.deployment
[1]: Empty string represents this was part of the all health checks publish. The goal is to have this tag match with
azure.functions.health_check.reports
so they can be joined into a single view/query in dashboards.[2]: The name of a health check should follow OTel attribute naming conventions itself.
Other Changes
ObjectPool<T>
usage, with helpers for getting shared pools. First shared pool introduced is forStringBuilder
. This allows for efficient re-usage of string builders when possible.Notes
We intend to use health checks to back liveness & readiness probes. As such, having metrics scoped to specific health check tags will be important to highlight directly the history of those probes. This is why
TelemetryHealthCheckPublisher
has theadditionalTags
parameter. This approach will lead to redundant metrics, as publishing metrics for the "default" (no tag) health check plus a tag-filtered health check will overlap.