-
Notifications
You must be signed in to change notification settings - Fork 730
/
ResourceUtilizationHealthCheckOptions.cs
47 lines (41 loc) · 1.73 KB
/
ResourceUtilizationHealthCheckOptions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// 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 Microsoft.Extensions.Diagnostics.ResourceMonitoring;
using Microsoft.Extensions.Options;
using Microsoft.Shared.Data.Validation;
namespace Microsoft.Extensions.Diagnostics.HealthChecks;
/// <summary>
/// Options for the resource utilization health check.
/// </summary>
public class ResourceUtilizationHealthCheckOptions
{
internal const int MinimumSamplingWindow = 100;
internal static readonly TimeSpan DefaultSamplingWindow = TimeSpan.FromSeconds(5);
/// <summary>
/// Gets or sets thresholds for CPU utilization.
/// </summary>
/// <remarks>
/// The thresholds are periodically compared against the utilization samples provided by
/// the registered <see cref="IResourceMonitor"/>.
/// </remarks>
[ValidateObjectMembers]
public ResourceUsageThresholds CpuThresholds { get; set; } = new ResourceUsageThresholds();
/// <summary>
/// Gets or sets thresholds for memory utilization.
/// </summary>
/// <remarks>
/// The thresholds are periodically compared against the utilization samples provided by
/// the registered <see cref="IResourceMonitor"/>.
/// </remarks>
[ValidateObjectMembers]
public ResourceUsageThresholds MemoryThresholds { get; set; } = new ResourceUsageThresholds();
/// <summary>
/// Gets or sets the time window for used for calculating CPU and memory utilization averages.
/// </summary>
/// <value>
/// The default value is 5 seconds.
/// </value>
[TimeSpan(MinimumSamplingWindow, int.MaxValue)]
public TimeSpan SamplingWindow { get; set; } = DefaultSamplingWindow;
}