290 references to HealthStatus
Aspire.Components.Common.TestUtilities (3)
ConformanceTests.cs (3)
381var expected = CanConnectToServer ? HealthStatus.Healthy : HealthStatus.Unhealthy;
Aspire.Dashboard (20)
Components\Pages\Resources.razor.cs (2)
220.Any(r => r.KnownState != KnownResourceState.Running || r.HealthStatus is HealthStatus.Unhealthy or HealthStatus.Degraded);
Model\ResourceIconHelpers.cs (4)
65public static (Icon? icon, Color color) GetHealthStatusIcon(HealthStatus? healthStatus) 69HealthStatus.Healthy => (new Icons.Filled.Size16.Heart(), Color.Success), 70HealthStatus.Degraded => (new Icons.Filled.Size16.HeartBroken(), Color.Warning), 71HealthStatus.Unhealthy => (new Icons.Filled.Size16.HeartBroken(), Color.Error),
Model\ResourceStateViewModel.cs (5)
84else if (resource.HealthStatus is HealthStatus.Unhealthy or HealthStatus.Degraded) 119else if (resource is { KnownState: KnownResourceState.Running, HealthStatus: not HealthStatus.Healthy }) 147{ KnownState: KnownResourceState.Running, HealthStatus: not HealthStatus.Healthy } => $"{resource.State.Humanize()} ({(resource.HealthStatus ?? HealthStatus.Unhealthy).Humanize()})",
Model\ResourceViewModel.cs (5)
42public HealthStatus? HealthStatus { get; private set; } 141internal static HealthStatus? ComputeHealthStatus(ImmutableArray<HealthReportViewModel> healthReports, KnownResourceState? state) 150? Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy 154?? Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Unhealthy; 440public sealed record class HealthReportViewModel(string Name, HealthStatus? HealthStatus, string? Description, string? ExceptionText)
ServiceClient\Partials.cs (4)
66Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus MapHealthStatus(HealthStatus healthStatus) 70HealthStatus.Healthy => Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, 71HealthStatus.Degraded => Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Degraded, 72HealthStatus.Unhealthy => Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Unhealthy,
Aspire.Dashboard.Components.Tests (9)
Controls\ResourceDetailsTests.cs (5)
451new HealthReportViewModel("zebra-check", HealthStatus.Healthy, "OK", null), 452new HealthReportViewModel("Alpha-Check", HealthStatus.Healthy, "OK", null), 453new HealthReportViewModel("beta-check", HealthStatus.Degraded, "Warning", null), 454new HealthReportViewModel("GAMMA-Check", HealthStatus.Healthy, "OK", null), 455new HealthReportViewModel("delta-check", HealthStatus.Unhealthy, "Failed", null)
Pages\ResourcesTests.cs (3)
78ImmutableArray.Create(new HealthReportViewModel("Healthy", HealthStatus.Healthy, "Description2", null)))) 130ImmutableArray.Create(new HealthReportViewModel("Healthy", HealthStatus.Healthy, "Description2", null))), 135ImmutableArray.Create(new HealthReportViewModel("Degraded", HealthStatus.Degraded, "Description3", null))),
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
22HealthStatus? reportHealthStatus = null,
Aspire.Dashboard.Tests (10)
Model\ResourceStateViewModelTests.cs (2)
71HealthStatus? healthStatus = string.IsNullOrEmpty(healthStatusString) ? null : Enum.Parse<HealthStatus>(healthStatusString);
Model\ResourceViewModelTests.cs (7)
10using DiagnosticsHealthStatus = Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus; 23[InlineData(KnownResourceState.Running, DiagnosticsHealthStatus.Healthy, new string[]{})] 24[InlineData(KnownResourceState.Running, DiagnosticsHealthStatus.Healthy, new string?[] {"Healthy"})] 25[InlineData(KnownResourceState.Running, DiagnosticsHealthStatus.Unhealthy, new string?[] {null})] 26[InlineData(KnownResourceState.Running, DiagnosticsHealthStatus.Degraded, new string?[] {"Healthy", "Degraded"})] 27public void Resource_WithHealthReportAndState_ReturnsCorrectHealthStatus(KnownResourceState? state, DiagnosticsHealthStatus? expectedStatus, string?[]? healthStatusStrings) 29var reports = healthStatusStrings?.Select<string?, HealthReportViewModel>((h, i) => new HealthReportViewModel(i.ToString(), h is null ? null : System.Enum.Parse<DiagnosticsHealthStatus>(h), null, null)).ToImmutableArray() ?? [];
tests\Shared\DashboardModel\ModelTestHelpers.cs (1)
22HealthStatus? reportHealthStatus = null,
Aspire.Hosting (19)
ApplicationModel\CustomResourceSnapshot.cs (6)
8using HealthStatus = Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus; 82public HealthStatus? HealthStatus { get; private set; } 147internal static HealthStatus? ComputeHealthStatus(ImmutableArray<HealthReportSnapshot> healthReports, string? state) 156? Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy 160?? Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Unhealthy; 306public sealed record HealthReportSnapshot(string Name, HealthStatus? Status, string? Description, string? ExceptionText)
ApplicationModel\ResourceNotificationService.cs (5)
150re => re.ResourceId == resourceId && re.Snapshot.HealthStatus == HealthStatus.Healthy, 224_logger.LogDebug("Waiting for resource '{ResourceName}' to enter the '{State}' state.", resourceName, HealthStatus.Healthy); 231if (resourceEvent.Snapshot.HealthStatus != HealthStatus.Healthy) 256WaitBehavior.WaitOnResourceUnavailable => snapshot.HealthStatus == HealthStatus.Healthy, 257WaitBehavior.StopOnResourceUnavailable => snapshot.HealthStatus == HealthStatus.Healthy ||
Dashboard\proto\Partials.cs (4)
122static HealthStatus MapHealthStatus(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus healthStatus) 126Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy => HealthStatus.Healthy, 127Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Degraded => HealthStatus.Degraded, 128Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Unhealthy => HealthStatus.Unhealthy,
Health\ResourceHealthCheckService.cs (2)
168report = new HealthReport(registrationKeysToCheck.ToDictionary(k => k, k => new HealthReportEntry(HealthStatus.Unhealthy, "Error calling HealthCheckService.", TimeSpan.Zero, ex, data: null)), TimeSpan.Zero); 175if (report.Status == HealthStatus.Healthy)
ResourceBuilderExtensions.cs (2)
1663/// return <see cref="Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy"/>.</para> 1700/// return <see cref="Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy"/>.</para>
Aspire.Hosting.Azure.Tests (1)
AzureEventHubsExtensionsTests.cs (1)
151Assert.Equal(HealthStatus.Healthy, healthCheckReport.Status);
Aspire.Hosting.GitHub.Models (3)
GitHubModelsExtensions.cs (3)
178/// <item>Return <see cref="HealthStatus.Healthy"/> when the endpoint returns HTTP 200</item> 179/// <item>Return <see cref="HealthStatus.Unhealthy"/> with details when the API key is invalid (HTTP 401)</item> 180/// <item>Return <see cref="HealthStatus.Unhealthy"/> with error details when the model is unknown (HTTP 404)</item>
Aspire.Hosting.OpenAI (4)
OpenAIExtensions.cs (4)
61failureStatus: HealthStatus.Unhealthy, 190/// <item>Return <see cref="HealthStatus.Healthy"/> when the endpoint returns HTTP 200</item> 191/// <item>Return <see cref="HealthStatus.Unhealthy"/> with details when the API key is invalid (HTTP 401)</item> 192/// <item>Return <see cref="HealthStatus.Unhealthy"/> with error details when the model is unknown (HTTP 404)</item>
Aspire.Hosting.Qdrant (1)
src\Components\Aspire.Qdrant.Client\QdrantHealthCheck.cs (1)
26: new HealthCheckResult(HealthStatus.Unhealthy);
Aspire.Hosting.Qdrant.Tests (1)
QdrantFunctionalTests.cs (1)
282await app.ResourceNotifications.WaitForResourceAsync(resource.Resource.Name, (re => re.Snapshot.HealthStatus == HealthStatus.Healthy), cts.Token);
Aspire.Hosting.Tests (19)
Backchannel\AuxiliaryBackchannelRpcTargetTests.cs (2)
109new HealthReportSnapshot("check1", Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, "All good", null), 110new HealthReportSnapshot("check2", Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Unhealthy, "Failed", "Exception occurred")
Health\HealthStatusTests.cs (6)
20[InlineData(RunningState, HealthStatus.Healthy, new string[]{})] 21[InlineData(RunningState, HealthStatus.Healthy, new string?[] {"Healthy"})] 22[InlineData(RunningState, HealthStatus.Unhealthy, new string?[] {null})] 23[InlineData(RunningState, HealthStatus.Degraded, new string?[] {"Healthy", "Degraded"})] 24public void Resource_WithHealthReportAndState_ReturnsCorrectHealthStatus(string? state, HealthStatus? expectedStatus, string?[]? healthStatusStrings) 26var reports = healthStatusStrings?.Select<string?, HealthReportSnapshot>((h, i) => new HealthReportSnapshot(i.ToString(), h is null ? null : Enum.Parse<HealthStatus>(h), null, null)).ToImmutableArray() ?? [];
Health\ResourceHealthCheckServiceTests.cs (9)
47Assert.Equal(HealthStatus.Healthy, healthyEvent.Snapshot.HealthStatus); 88Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 130e => e.Snapshot.State?.Text == KnownResourceStates.Running && e.Snapshot.HealthReports.Single().Status == HealthStatus.Unhealthy).DefaultTimeout(); 132Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 597Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 604Assert.Equal(HealthStatus.Healthy, healthyEvent.Snapshot.HealthStatus); 643Assert.Equal(HealthStatus.Unhealthy, runningEvent.Snapshot.HealthStatus); 649var unhealthyEvent = await app.ResourceNotifications.WaitForResourceAsync("resource", e => e.Snapshot.HealthStatus == HealthStatus.Unhealthy).DefaultTimeout(); 650Assert.Equal(HealthStatus.Unhealthy, unhealthyEvent.Snapshot.HealthStatus);
ResourceNotificationTests.cs (2)
648Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus); 716Assert.Equal(Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus.Healthy, resourceEvent.Snapshot.HealthStatus);
Aspire.Milvus.Client (1)
MilvusHealthCheck.cs (1)
28: new HealthCheckResult(HealthStatus.Unhealthy, description: milvusHealthState.ToString());
Aspire.Qdrant.Client (1)
QdrantHealthCheck.cs (1)
26: new HealthCheckResult(HealthStatus.Unhealthy);
HealthChecksSandbox.AppHost (6)
Program.cs (6)
13AddTestResource("healthy", HealthStatus.Healthy, "I'm fine, thanks for asking."); 14AddTestResource("unhealthy", HealthStatus.Unhealthy, "I can't do that, Dave.", exceptionMessage: "Feeling unhealthy."); 15AddTestResource("degraded", HealthStatus.Degraded, "Had better days.", exceptionMessage: "Feeling degraded."); 29void AddTestResource(string name, HealthStatus status, string? description = null, string? exceptionMessage = null) 42return new HealthCheckResult(HealthStatus.Unhealthy, "Initial failure state."); 45return new HealthCheckResult(HealthStatus.Healthy, "Healthy beginning second health check run.");
Microsoft.AspNetCore.Diagnostics.HealthChecks (26)
HealthCheckMiddleware.cs (1)
52$"No status code mapping found for {nameof(HealthStatus)} value: {result.Status}." +
HealthCheckOptions.cs (19)
25private IDictionary<HealthStatus, int> _resultStatusCodes = new Dictionary<HealthStatus, int>(DefaultStatusCodesMapping); 27private static readonly IReadOnlyDictionary<HealthStatus, int> DefaultStatusCodesMapping = new Dictionary<HealthStatus, int> 29{HealthStatus.Healthy, StatusCodes.Status200OK}, 30{HealthStatus.Degraded, StatusCodes.Status200OK}, 31{HealthStatus.Unhealthy, StatusCodes.Status503ServiceUnavailable}, 35/// Gets or sets a dictionary mapping the <see cref="HealthStatus"/> to an HTTP status code applied 40/// <see cref="HealthStatus.Healthy"/> to 200 (OK), <see cref="HealthStatus.Degraded"/> to 200 (OK) and 41/// <see cref="HealthStatus.Unhealthy"/> to 503 (Service Unavailable). 43/// <exception cref="InvalidOperationException">Thrown if at least one <see cref="HealthStatus"/> is missing when setting this property.</exception> 44public IDictionary<HealthStatus, int> ResultStatusCodes 47set => _resultStatusCodes = value != null ? ValidateStatusCodesMapping(value) : new Dictionary<HealthStatus, int>(DefaultStatusCodesMapping); 50private static IDictionary<HealthStatus, int> ValidateStatusCodesMapping(IDictionary<HealthStatus, int> mapping) 52var missingHealthStatus = Enum.GetValues<HealthStatus>().Except(mapping.Keys).ToList(); 55var missing = string.Join(", ", missingHealthStatus.Select(status => $"{nameof(HealthStatus)}.{status}")); 58$"{nameof(HealthStatus)} values. Missing: {missing}";
HealthCheckResponseWriters.cs (6)
12private static readonly byte[] DegradedBytes = Encoding.UTF8.GetBytes(HealthStatus.Degraded.ToString()); 13private static readonly byte[] HealthyBytes = Encoding.UTF8.GetBytes(HealthStatus.Healthy.ToString()); 14private static readonly byte[] UnhealthyBytes = Encoding.UTF8.GetBytes(HealthStatus.Unhealthy.ToString()); 21HealthStatus.Degraded => httpContext.Response.Body.WriteAsync(DegradedBytes.AsMemory()).AsTask(), 22HealthStatus.Healthy => httpContext.Response.Body.WriteAsync(HealthyBytes.AsMemory()).AsTask(), 23HealthStatus.Unhealthy => httpContext.Response.Body.WriteAsync(UnhealthyBytes.AsMemory()).AsTask(),
Microsoft.Extensions.Diagnostics.HealthChecks (41)
_generated\0\LoggerMessage.g.cs (12)
27private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, global::System.Exception?> __HealthCheckProcessingEndCallback = 28global::Microsoft.Extensions.Logging.LoggerMessage.Define<global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double>(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(101, "HealthCheckProcessingEnd"), "Health check processing with combined status {HealthStatus} completed after {ElapsedMilliseconds}ms", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); 35private static partial void HealthCheckProcessingEnd(global::Microsoft.Extensions.Logging.ILogger logger, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus HealthStatus, double ElapsedMilliseconds) 59private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?, global::System.Exception?> __HealthCheckEndHealthyCallback = 60global::Microsoft.Extensions.Logging.LoggerMessage.Define<string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?>(global::Microsoft.Extensions.Logging.LogLevel.Debug, new global::Microsoft.Extensions.Logging.EventId(103, "HealthCheckEnd"), "Health check {HealthCheckName} with status {HealthStatus} completed after {ElapsedMilliseconds}ms with message '{HealthCheckDescription}'", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); 67private static partial void HealthCheckEndHealthy(global::Microsoft.Extensions.Logging.ILogger logger, string HealthCheckName, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription) 75private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?, global::System.Exception?> __HealthCheckEndDegradedCallback = 76global::Microsoft.Extensions.Logging.LoggerMessage.Define<string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?>(global::Microsoft.Extensions.Logging.LogLevel.Warning, new global::Microsoft.Extensions.Logging.EventId(103, "HealthCheckEnd"), "Health check {HealthCheckName} with status {HealthStatus} completed after {ElapsedMilliseconds}ms with message '{HealthCheckDescription}'", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); 83private static partial void HealthCheckEndDegraded(global::Microsoft.Extensions.Logging.ILogger logger, string HealthCheckName, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription, global::System.Exception? exception) 91private static readonly global::System.Action<global::Microsoft.Extensions.Logging.ILogger, string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?, global::System.Exception?> __HealthCheckEndUnhealthyCallback = 92global::Microsoft.Extensions.Logging.LoggerMessage.Define<string, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus, double, string?>(global::Microsoft.Extensions.Logging.LogLevel.Error, new global::Microsoft.Extensions.Logging.EventId(103, "HealthCheckEnd"), "Health check {HealthCheckName} with status {HealthStatus} completed after {ElapsedMilliseconds}ms with message '{HealthCheckDescription}'", new global::Microsoft.Extensions.Logging.LogDefineOptions() { SkipEnabledCheck = true }); 99private static partial void HealthCheckEndUnhealthy(global::Microsoft.Extensions.Logging.ILogger logger, string HealthCheckName, global::Microsoft.Extensions.Diagnostics.HealthChecks.HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription, global::System.Exception? exception)
DefaultHealthCheckService.cs (8)
208public static void HealthCheckProcessingEnd(ILogger logger, HealthStatus status, TimeSpan duration) => 212private static partial void HealthCheckProcessingEnd(ILogger logger, HealthStatus HealthStatus, double ElapsedMilliseconds); 221private static partial void HealthCheckEndHealthy(ILogger logger, string HealthCheckName, HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription); 224private static partial void HealthCheckEndDegraded(ILogger logger, string HealthCheckName, HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription, Exception? exception); 227private static partial void HealthCheckEndUnhealthy(ILogger logger, string HealthCheckName, HealthStatus HealthStatus, double ElapsedMilliseconds, string? HealthCheckDescription, Exception? exception); 233case HealthStatus.Healthy: 237case HealthStatus.Degraded: 241case HealthStatus.Unhealthy:
DependencyInjection\HealthChecksBuilderAddCheckExtensions.cs (21)
24/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 25/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 34HealthStatus? failureStatus, 47/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 48/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 58HealthStatus? failureStatus = null, 76/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 77/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 91HealthStatus? failureStatus, 104/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 105/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 119HealthStatus? failureStatus = null, 166/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 167/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 179HealthStatus? failureStatus, 195/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 196/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 209HealthStatus? failureStatus, 231/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 232/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 246HealthStatus? failureStatus,
Microsoft.Extensions.Diagnostics.HealthChecks.Abstractions (34)
HealthCheckRegistration.cs (14)
40public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable<string>? tags) 51/// The <see cref="HealthStatus"/> that should be reported upon failure of the health check. If the provided value 52/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 56public HealthCheckRegistration(string name, IHealthCheck instance, HealthStatus? failureStatus, IEnumerable<string>? tags, TimeSpan? timeout) 67FailureStatus = failureStatus ?? HealthStatus.Unhealthy; 79/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 80/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 86HealthStatus? failureStatus, 98/// The <see cref="HealthStatus"/> that should be reported when the health check reports a failure. If the provided value 99/// is <c>null</c>, then <see cref="HealthStatus.Unhealthy"/> will be reported. 106HealthStatus? failureStatus, 119FailureStatus = failureStatus ?? HealthStatus.Unhealthy; 140/// Gets or sets the <see cref="HealthStatus"/> that should be reported upon failure of the health check. 142public HealthStatus FailureStatus { get; set; }
HealthCheckResult.cs (5)
24public HealthCheckResult(HealthStatus status, string? description = null, Exception? exception = null, IReadOnlyDictionary<string, object>? data = null) 50public HealthStatus Status { get; } 60return new HealthCheckResult(status: HealthStatus.Healthy, description, exception: null, data); 72return new HealthCheckResult(status: HealthStatus.Degraded, description, exception: exception, data); 84return new HealthCheckResult(status: HealthStatus.Unhealthy, description, exception, data);
HealthReport.cs (9)
31/// <param name="status">A <see cref="HealthStatus"/> representing the aggregate status of all the health checks.</param> 33public HealthReport(IReadOnlyDictionary<string, HealthReportEntry> entries, HealthStatus status, TimeSpan totalDuration) 50/// Gets a <see cref="HealthStatus"/> representing the aggregate status of all the health checks. The value of <see cref="Status"/> 51/// will be the most severe status reported by a health check. If no checks were executed, the value is always <see cref="HealthStatus.Healthy"/>. 53public HealthStatus Status { get; } 60private static HealthStatus CalculateAggregateStatus(IEnumerable<HealthReportEntry> entries) 63var currentValue = HealthStatus.Healthy; 70if (currentValue == HealthStatus.Unhealthy)
HealthReportEntry.cs (3)
26public HealthReportEntry(HealthStatus status, string? description, TimeSpan duration, Exception? exception, IReadOnlyDictionary<string, object>? data) 41public HealthReportEntry(HealthStatus status, string? description, TimeSpan duration, Exception? exception, IReadOnlyDictionary<string, object>? data, IEnumerable<string>? tags = null) 74public HealthStatus Status { get; }
HealthStatus.cs (3)
15/// The values of this enum or ordered from least healthy to most healthy. So <see cref="HealthStatus.Degraded"/> is 16/// greater than <see cref="HealthStatus.Unhealthy"/> but less than <see cref="HealthStatus.Healthy"/>.
Microsoft.Extensions.Diagnostics.HealthChecks.Common (9)
Log.cs (2)
14HealthStatus status, 20HealthStatus status);
ManualHealthCheckTracker.cs (3)
34var worstStatus = HealthStatus.Healthy; 38if (check.Status != HealthStatus.Healthy)
Metric.cs (2)
17public static void RecordMetric(this HealthCheckReportCounter counterMetric, HealthStatus status) 20public static void RecordMetric(this UnhealthyHealthCheckCounter counterMetric, string name, HealthStatus status)
TelemetryHealthCheckPublisher.cs (2)
46if (report.Status == HealthStatus.Healthy) 61if (entry.Value.Status != HealthStatus.Healthy)
Microsoft.Extensions.Diagnostics.HealthChecks.Common.Tests (44)
ApplicationLifecycleHealthCheckTests.cs (4)
19Assert.Equal(HealthStatus.Unhealthy, (await healthCheck.CheckHealthAsync(context, CancellationToken.None)).Status); 22Assert.Equal(HealthStatus.Healthy, (await healthCheck.CheckHealthAsync(context, CancellationToken.None)).Status); 25Assert.Equal(HealthStatus.Unhealthy, (await healthCheck.CheckHealthAsync(context, CancellationToken.None)).Status); 28Assert.Equal(HealthStatus.Unhealthy, (await healthCheck.CheckHealthAsync(context, CancellationToken.None)).Status);
ManualHealthCheckTests.cs (12)
21Assert.Equal(HealthStatus.Healthy, healthCheckResult.Status); 25Assert.Equal(HealthStatus.Unhealthy, manualHealthCheck.Result.Status); 38Assert.Equal(HealthStatus.Unhealthy, (await manualHealthCheckService.CheckHealthAsync(context, CancellationToken.None)).Status); 43Assert.Equal(HealthStatus.Unhealthy, healthCheckResultUnhealthy.Status); 48Assert.Equal(HealthStatus.Healthy, healthCheckResultHealthy.Status); 62Assert.Equal(HealthStatus.Unhealthy, (await manualHealthCheckService.CheckHealthAsync(context, CancellationToken.None)).Status); 68Assert.Equal(HealthStatus.Unhealthy, healthCheckResultUnhealthy.Status); 74Assert.Equal(HealthStatus.Healthy, healthCheckResultHealthy.Status); 89Assert.Equal(HealthStatus.Unhealthy, (await manualHealthCheckService.CheckHealthAsync(context, CancellationToken.None)).Status); 97Assert.Equal(HealthStatus.Unhealthy, healthCheckResult2Unhealthy.Status); 104Assert.Equal(HealthStatus.Unhealthy, healthCheckResult1Unhealthy.Status); 111Assert.Equal(HealthStatus.Healthy, healthCheckResultHealthy.Status);
TelemetryHealthChecksPublisherTests.cs (28)
23public static TheoryData<List<HealthStatus>, bool, int, string, LogLevel, string> PublishAsyncArgs => new() 26new List<HealthStatus> { HealthStatus.Healthy }, 31HealthStatus.Healthy.ToString() 34new List<HealthStatus> { HealthStatus.Degraded }, 39HealthStatus.Degraded.ToString() 42new List<HealthStatus> { HealthStatus.Unhealthy }, 47HealthStatus.Unhealthy.ToString() 50new List<HealthStatus> { HealthStatus.Healthy, HealthStatus.Healthy }, 55HealthStatus.Healthy.ToString() 58new List<HealthStatus> { HealthStatus.Healthy, HealthStatus.Unhealthy }, 63HealthStatus.Unhealthy.ToString() 66new List<HealthStatus> { HealthStatus.Healthy, HealthStatus.Degraded, HealthStatus.Unhealthy }, 72HealthStatus.Unhealthy.ToString() 79IList<HealthStatus> healthStatuses, 120var healthStatus = healthStatuses[i]; 121if (healthStatus != HealthStatus.Healthy) 152private static HealthReport CreateHealthReport(IEnumerable<HealthStatus> healthStatuses) 157foreach (var status in healthStatuses)
Microsoft.Extensions.Diagnostics.HealthChecks.EntityFrameworkCore (3)
DependencyInjection\EntityFrameworkCoreHealthChecksBuilderExtensions.cs (3)
26/// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then 27/// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported. 55HealthStatus? failureStatus = default,
Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests (30)
HealthCheckTestData.cs (12)
16HealthStatus.Healthy, 26HealthStatus.Healthy, 36HealthStatus.Healthy, 46HealthStatus.Degraded, 56HealthStatus.Unhealthy, 66HealthStatus.Unhealthy, 76HealthStatus.Degraded, 86HealthStatus.Unhealthy, 96HealthStatus.Degraded, 106HealthStatus.Degraded, 116HealthStatus.Unhealthy, 126HealthStatus.Unhealthy,
Linux\LinuxResourceHealthCheckTests.cs (14)
25HealthStatus.Healthy, 35HealthStatus.Healthy, 45HealthStatus.Healthy, 55HealthStatus.Degraded, 65HealthStatus.Unhealthy, 75HealthStatus.Unhealthy, 85HealthStatus.Degraded, 95HealthStatus.Unhealthy, 105HealthStatus.Degraded, 115HealthStatus.Degraded, 125HealthStatus.Unhealthy, 135HealthStatus.Unhealthy, 149HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory, 237if (healthCheckResult.Status != HealthStatus.Healthy)
ResourceHealthCheckExtensionsTests.cs (2)
471HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory, 552if (healthCheckResult.Status != HealthStatus.Healthy)
ResourceHealthCheckTests.cs (2)
17public async Task TestCpuAndMemoryChecks(HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory, 49if (healthCheckResult.Status != HealthStatus.Healthy)
Microsoft.Extensions.Diagnostics.Probes (1)
TcpEndpointProbesService.cs (1)
44if (report.Status == HealthStatus.Healthy)
Microsoft.Extensions.Diagnostics.Probes.Tests (3)
MockHealthCheckService.cs (3)
14private readonly Task<HealthReport> _healthyReport = CreateHealthReport(HealthStatus.Healthy); 15private readonly Task<HealthReport> _unhealthyReport = CreateHealthReport(HealthStatus.Unhealthy); 23private static Task<HealthReport> CreateHealthReport(HealthStatus healthStatus)
Testing.Tests (1)
WaitFailures.cs (1)
176await app.ResourceNotifications.WaitForResourceAsync(nginx.Resource.Name, x => x.Snapshot.HealthStatus == HealthStatus.Healthy, cts.Token);