-
Notifications
You must be signed in to change notification settings - Fork 765
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make HealthChecks.ResourceUtilization use observable instruments (#5798)
- Loading branch information
1 parent
acc985a
commit 2534f08
Showing
11 changed files
with
610 additions
and
166 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
...s.Diagnostics.HealthChecks.ResourceUtilization/ResourceUtilizationHealthCheck.Obsolete.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
using System.Threading; | ||
using System.Threading.Tasks; | ||
using Microsoft.Extensions.Diagnostics.ResourceMonitoring; | ||
using Microsoft.Shared.DiagnosticIds; | ||
using Microsoft.Shared.Diagnostics; | ||
|
||
namespace Microsoft.Extensions.Diagnostics.HealthChecks; | ||
|
||
/// <summary> | ||
/// Represents a health check for in-container resources <see cref="IHealthCheck"/>. | ||
/// </summary> | ||
internal sealed partial class ResourceUtilizationHealthCheck : IHealthCheck | ||
{ | ||
#pragma warning disable CS0436 // Type conflicts with imported type | ||
[Obsolete(DiagnosticIds.Obsoletions.NonObservableResourceMonitoringApiMessage, | ||
DiagnosticId = DiagnosticIds.Obsoletions.NonObservableResourceMonitoringApiDiagId, | ||
UrlFormat = DiagnosticIds.UrlFormat)] | ||
public void ObsoleteConstructor(IResourceMonitor dataTracker) => _dataTracker = Throw.IfNull(dataTracker); | ||
|
||
/// <summary> | ||
/// Runs the health check. | ||
/// </summary> | ||
/// <param name="cancellationToken">A <see cref="CancellationToken"/> that can be used to cancel the health check.</param> | ||
/// <returns>A <see cref="Task{HealthCheckResult}"/> that completes when the health check has finished, yielding the status of the component being checked.</returns> | ||
#pragma warning disable IDE0060 // Remove unused parameter | ||
[Obsolete(DiagnosticIds.Obsoletions.NonObservableResourceMonitoringApiMessage, | ||
DiagnosticId = DiagnosticIds.Obsoletions.NonObservableResourceMonitoringApiDiagId, | ||
UrlFormat = DiagnosticIds.UrlFormat)] | ||
public Task<HealthCheckResult> ObsoleteCheckHealthAsync(CancellationToken cancellationToken = default) | ||
{ | ||
var utilization = _dataTracker!.GetUtilization(_options.SamplingWindow); | ||
return ResourceUtilizationHealthCheck.EvaluateHealthStatusAsync(utilization.CpuUsedPercentage, utilization.MemoryUsedPercentage, _options); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.