You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
public static class UrisHealthCheckBuilderExtensions
{
///
/// Add a health check for single uri.
///
/// The .
/// The uri to check.
/// The health check name. Optional. If null the type name 'uri-group' will be used for the name.
///
/// The that should be reported when the health check fails. If null then
/// the default status of will be reported.
///
/// A list of tags that can be used to filter sets of health checks.
/// The proxy for http request. Optional
/// The .
public static IHealthChecksBuilder AddUrlGroup(this IHealthChecksBuilder builder, Uri uri, string name, Uri proxy,
HealthStatus? failureStatus = null, IEnumerable tags = null)
{
if (proxy == null)
{
builder.Services.AddHttpClient("HealthCheck");
}
else
{
builder.Services
.AddHttpClient("HealthCheck")
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
{
Proxy = new WebProxy(proxy)
});
}
var options = new UriHealthCheckOptions();
options.AddUri(uri);
var registrationName = name;
return builder.Add(new HealthCheckRegistration(
registrationName,
sp => CreateHealthCheck(sp, registrationName, options),
failureStatus,
tags));
}
private static UriHealthCheck CreateHealthCheck(IServiceProvider sp, string name, UriHealthCheckOptions options)
{
var httpClientFactory = sp.GetRequiredService<IHttpClientFactory>();
return new UriHealthCheck(options, () => httpClientFactory.CreateClient("HealthCheck"));
}
}
The text was updated successfully, but these errors were encountered:
Add extensions for health checks:
Notes:
Report and writer
Tests
The text was updated successfully, but these errors were encountered: