Skip to content

Commit

Permalink
initial commit (#42626)
Browse files Browse the repository at this point in the history
  • Loading branch information
evgenyfedorov2 authored Oct 5, 2024
1 parent 87af0bb commit a60aa02
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 7 deletions.
4 changes: 0 additions & 4 deletions docs/core/diagnostics/diagnostic-health-checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,12 @@ To perform health checks on the resource utilization of your .NET apps, add a pa
The preceding code:

- Creates a new <xref:Microsoft.Extensions.Hosting.HostApplicationBuilder> instance.
- Adds resource monitoring by calling <xref:Microsoft.Extensions.DependencyInjection.ResourceMonitoringServiceCollectionExtensions.AddResourceMonitoring%2A>.
- Adds a health check for resource utilization by chaining a call from the <xref:Microsoft.Extensions.DependencyInjection.HealthCheckServiceCollectionExtensions.AddHealthChecks%2A> call to the <xref:Microsoft.Extensions.DependencyInjection.ResourceUtilizationHealthCheckExtensions.AddResourceUtilizationHealthCheck%2A> extension method.
- Builds the <xref:Microsoft.Extensions.Hosting.IHost> instance as the `app` variable.
- Gets an instance of the <xref:Microsoft.Extensions.Diagnostics.HealthChecks.HealthCheckService> class from the service provider.
- Performs a health check and displays the result.
- Runs the application.

> [!NOTE]
> The `Microsoft.Extensions.Diagnostics.HealthChecks.ResourceUtilization` library assumes that the consumer will register the dependent call to <xref:Microsoft.Extensions.DependencyInjection.ResourceMonitoringServiceCollectionExtensions.AddResourceMonitoring%2A>. If you don't register this, when resolving the `HealthCheckService` an exception is thrown.
## Application lifetime health checks

To perform health checks on the application lifetime events of <xref:Microsoft.Extensions.Hosting.IHostApplicationLifetime>, use the <xref:Microsoft.Extensions.DependencyInjection.CommonHealthChecksExtensions.AddApplicationLifecycleHealthCheck%2A> extension method available in the [Microsoft.Extensions.Diagnostics.HealthChecks.Common](https://www.nuget.org/packages/Microsoft.Extensions.Diagnostics.HealthChecks.Common) NuGet package.
Expand Down
3 changes: 0 additions & 3 deletions docs/core/diagnostics/snippets/health-checks/Program.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Microsoft.Extensions.Diagnostics.ResourceMonitoring;
using Microsoft.Extensions.Hosting;

var builder = Host.CreateApplicationBuilder(args);

builder.Services.AddResourceMonitoring();

builder.Services.AddHealthChecks()
.AddResourceUtilizationHealthCheck();

Expand Down

0 comments on commit a60aa02

Please sign in to comment.