292 references to HealthStatus
Aspire.Components.Common.TestUtilities (3)
Aspire.Dashboard (20)
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))),
Aspire.Dashboard.Tests (10)
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() ?? [];
Aspire.Hosting (19)
Aspire.Hosting.Azure.Tests (1)
Aspire.Hosting.GitHub.Models (3)
Aspire.Hosting.OpenAI (4)
Aspire.Hosting.Qdrant (1)
Aspire.Hosting.Qdrant.Tests (1)
Aspire.Hosting.Tests (19)
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() ?? [];
Aspire.Milvus.Client (1)
Aspire.Qdrant.Client (1)
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)
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}";
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);
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; }
Microsoft.Extensions.Diagnostics.HealthChecks.Common (11)
Microsoft.Extensions.Diagnostics.HealthChecks.Common.Tests (44)
..\..\..\..\test\Libraries\Microsoft.Extensions.Diagnostics.HealthChecks.Common.Tests\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);
..\..\..\..\test\Libraries\Microsoft.Extensions.Diagnostics.HealthChecks.Common.Tests\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)
Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests (30)
..\..\..\..\test\Libraries\Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests\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,
..\..\..\..\test\Libraries\Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization.Tests\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,
148HealthStatus expected, double utilization, ulong memoryUsed, ulong totalMemory,
238if (healthCheckResult.Status != HealthStatus.Healthy)
Microsoft.Extensions.Diagnostics.Probes (1)
Microsoft.Extensions.Diagnostics.Probes.Tests (3)
Testing.Tests (1)