HealthChecks.OpenTelemetry.Instrumentation
1.0.0-dev.7
See the version list below for details.
dotnet add package HealthChecks.OpenTelemetry.Instrumentation --version 1.0.0-dev.7
NuGet\Install-Package HealthChecks.OpenTelemetry.Instrumentation -Version 1.0.0-dev.7
<PackageReference Include="HealthChecks.OpenTelemetry.Instrumentation" Version="1.0.0-dev.7" />
paket add HealthChecks.OpenTelemetry.Instrumentation --version 1.0.0-dev.7
#r "nuget: HealthChecks.OpenTelemetry.Instrumentation, 1.0.0-dev.7"
// Install HealthChecks.OpenTelemetry.Instrumentation as a Cake Addin #addin nuget:?package=HealthChecks.OpenTelemetry.Instrumentation&version=1.0.0-dev.7&prerelease // Install HealthChecks.OpenTelemetry.Instrumentation as a Cake Tool #tool nuget:?package=HealthChecks.OpenTelemetry.Instrumentation&version=1.0.0-dev.7&prerelease
HealthChecks Instrumentation for OpenTelemetry .NET
This is an Instrumentation Library, which instruments Microsoft.Extensions.Diagnostics.HealthChecks and collect telemetry about the application health checks.
Steps to enable HealthChecks.OpenTelemetry.Instrumentation
Step 1: Install package
Add a reference to the HealthChecks.OpenTelemetry.Instrumentation
package.
dotnet add package HealthChecks.OpenTelemetry.Instrumentation
Step 2: Enable HealthChecks Instrumentation
HealthChecks instrumentation should be enabled at application startup using the AddHealthChecksInstrumentation
extension on MeterProviderBuilder
. The following example demonstrates adding HealthChecks instrumentation to a console application. This example also sets up the OpenTelemetry Console exporter, which requires adding the package OpenTelemetry.Exporter.Console
to the application:
using OpenTelemetry;
using OpenTelemetry.Metrics;
public class Program
{
public static void Main(string[] args)
{
using var meterProvider = Sdk.CreateMeterProviderBuilder()
.AddHealthChecksInstrumentation()
.AddConsoleExporter()
.Build();
}
}
For an ASP.NET Core application, adding instrumentation is typically done in the ConfigureServices
of your Startup
class. Refer to documentation for OpenTelemetry.Instrumentation.AspNetCore.
Refer to Program.cs for a complete demo.
Advanced configuration
This instrumentation can be configured to change the default behavior by using HealthChecksInstrumentationOptions
.
services.AddOpenTelemetry()
.WithMetrics(builder => builder
.AddHealthChecksInstrumentation(options =>
{
options.StatusGaugeName = "myapp_health";
options.DurationGaugeName = "myapp_health_duration";
})
.AddConsoleExporter());
When used with OpenTelemetry.Extensions.Hosting
, all configurations to HealthChecksInstrumentationOptions
can be done in the ConfigureServices
method of you applications Startup
class as shown below.
// Configure
services.Configure<HealthChecksInstrumentationOptions>(options =>
{
options.StatusGaugeName = "myapp_health";
options.DurationGaugeName = "myapp_health_duration";
});
services.AddOpenTelemetry()
.WithMetrics(builder => builder
.AddHealthChecksInstrumentation()
.AddConsoleExporter());
Metrics
aspnetcore_healthcheck
Gets the health status of the component that was checked, converted to double value (0 == Unhealthy, 0.5 == Degraded, 1 == Healthy).
Units | Instrument Type | Value Type | Attribute Key(s) | Attribute Values |
---|---|---|---|---|
status |
ObservableGauge | Double |
name | name of each executed health check |
The API used to retrieve the value is:
- HealthReportEntry.Status: Gets the health status of the component that was checked.
aspnetcore_healthcheck_duration
Gets the health check execution duration.
Units | Instrument Type | Value Type | Attribute Key(s) | Attribute Values |
---|---|---|---|---|
seconds |
ObservableGauge | Double |
name | name of each executed health check |
The API used to retrieve the value is:
- HealthReportEntry.Duration: Gets the health check execution duration.
References
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
.NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
.NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen40 was computed. tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 7.0.11)
- OpenTelemetry.Api.ProviderBuilderExtensions (>= 1.6.0)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on HealthChecks.OpenTelemetry.Instrumentation:
Package | Downloads |
---|---|
Fluxera.Extensions.Hosting.Modules.HealthChecks
A module that enables health checks. |
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated |
---|---|---|
1.1.0-dev.8 | 27,594 | 5/9/2024 |
1.0.0-dev.7 | 28,016 | 9/30/2023 |