/// <summary> /// Add a <see cref="IHealthCheck"/> that queries SQL Server to determine availability. /// </summary> /// <param name="builder"></param> /// <param name="name">Name of the <see cref="IHealthCheck"/></param> /// <param name="connectionString">Connection String for the Database to query.</param> /// <returns><see cref="IHealthChecksBuilder"/></returns> public static IHealthChecksBuilder AddSqlServerHealthCheck(this IHealthChecksBuilder builder, string name, string connectionString) { builder.AddTypeActivatedCheck <SqlServerHealthCheck>(name, failureStatus: HealthStatus.Unhealthy, tags: new[] { "details" }, args: connectionString); return(builder); }
/// <summary> /// Add an Http based <see cref="IHealthCheck"/>. /// </summary> /// <param name="builder"></param> /// <param name="name">Name of the <see cref="IHealthCheck"/></param> /// <param name="urlPath">Url Path that will be added to the BaseAddress of <c>IHttpClientFactory</c></param> /// <returns><see cref="IHealthChecksBuilder"/></returns> public static IHealthChecksBuilder AddHttpHealthCheck(this IHealthChecksBuilder builder, string name, string urlPath) { builder.AddTypeActivatedCheck <HttpHealthCheck>(name, failureStatus: HealthStatus.Unhealthy, tags: new[] { "details" }, args: urlPath); return(builder); }
public static IHealthChecksBuilder AddDIObjectHealthCheck <T>(this IHealthChecksBuilder builder, Func <T, bool> testfunc) { var serviceCollection = builder.Services; var name = typeof(T).Name; return(builder.AddTypeActivatedCheck <DIObjectChecker <T> >($"DIObjectHealthCheck {name}", null, null, serviceCollection, testfunc)); }
private void ConfigureHealthChecks(IHealthChecksBuilder builder) { var config = Configuration.Get <AppConfig>(); foreach (var worker in config.Workers) { builder.AddTypeActivatedCheck <WorkerHealthCheck>($"worker_{worker.Id}", worker.Id); } }
public static IHealthChecksBuilder AddApiIsAliveAndWell(this IHealthChecksBuilder builder, IConfiguration clientOptions, string isAliveAndWellUrl = "Health/IsAliveAndWell", TimeSpan?cacheDuration = null) { ApiServiceConfiguration config = new ApiServiceConfiguration(); string sectionPath = ""; if (clientOptions is Microsoft.Extensions.Configuration.ConfigurationSection) { sectionPath = (clientOptions as Microsoft.Extensions.Configuration.ConfigurationSection).Path; } clientOptions.Bind(config); string path = string.Format(config.BaseAddress + isAliveAndWellUrl); return(builder.AddTypeActivatedCheck <ServiceClientBaseHealthCheck>($"ApiIsAlive {path} {sectionPath}", null, null, config, path)); }
/// <summary> /// Add http endpoint health check /// </summary> /// <param name="builder">health checks builder</param> /// <param name="name">name of the health check</param> /// <param name="endpointName">name of the endpoint to check</param> /// <param name="relativePath">relative path to check, absolute path not allowed</param> /// <param name="method">http method to use, defaults to HttpGet</param> /// <param name="scheme">uri scheme, defaults to http</param> /// <param name="expectedStatus">response status code that considered healthy, default to 200(OK)</param> /// <param name="additionalCheck">action that would be called after getting response, function should return new result object that would be reported</param> /// <param name="reportData">additional properties that will be attached to health check result, for example escalation info</param> public static IHealthChecksBuilder AddHttpEndpointCheck( this IHealthChecksBuilder builder, string name, string endpointName, string relativePath, HttpMethod?method = null, string?scheme = null, HttpStatusCode?expectedStatus = null, Func <HttpResponseMessage, HealthCheckResult, HealthCheckResult>?additionalCheck = null, params KeyValuePair <string, object>[] reportData) { return(builder.AddTypeActivatedCheck <HttpEndpointHealthCheck>( name, new HttpHealthCheckParameters(endpointName, new Uri(relativePath, UriKind.Relative), method, scheme, expectedStatus, additionalCheck, reportData))); }
public static IHealthChecksBuilder AddDIHealthCheck(this IHealthChecksBuilder builder, IServiceCollection services) { //return builder.AddCheck($"DIHealthCheck", new DIHealthCheck(services)); return(builder.AddTypeActivatedCheck <DIHealthCheck>($"DIHealthCheck", null, null, services)); }
public static IHealthChecksBuilder AddMongoHealthCheck(this IHealthChecksBuilder builder, string connectionString) { return(builder.AddTypeActivatedCheck <MongoHealthCheck>($"MongoHealthCheck", null, null, connectionString)); }
public static IHealthChecksBuilder SqlConnectionHealthCheck(this IHealthChecksBuilder builder, string connectionString, string testQuery) { //return builder.AddCheck($"SqlConnectionHealthCheck {connectionString} + {testQuery}", new SqlConnectionHealthCheck(connectionString, testQuery)); return(builder.AddTypeActivatedCheck <SqlConnectionHealthCheck>($"SqlConnectionHealthCheck {connectionString} + {testQuery}", null, null, connectionString, testQuery)); }
public static IHealthChecksBuilder AddRedisHealthCheck(this IHealthChecksBuilder builder, string connectionString) { return(builder.AddTypeActivatedCheck <RedisHealthCheck>($"RedisHealthCheck {connectionString}", null, null, connectionString)); }
public static IHealthChecksBuilder AddHttpGetCheck(this IHealthChecksBuilder builder, string url) { //return builder.AddCheck($"UrlGetCheck {url}", new HttpGetCheck(url)); return(builder.AddTypeActivatedCheck <HttpGetCheck>($"UrlGetCheck {url}", null, null, url)); }
public static IHealthChecksBuilder AddProcessList(this IHealthChecksBuilder builder, TimeSpan?cacheDuration = null) { return(builder.AddTypeActivatedCheck <ProcessListHealthChecks>($"ProcessList (KB)")); }
/// <summary> /// Adds health checks around the Mongo database, and naming them appropriately so they can be reported properly. /// </summary> /// <param name="builder">The health check builder.</param> public static IHealthChecksBuilder AddMongoDbHealthChecks(this IHealthChecksBuilder builder) { builder.AddTypeActivatedCheck <MongoDbHealthCheck>(nameof(MongoDbHealthCheck)); return(builder); }
public static IHealthChecksBuilder AddRabbitMQHealthCheckWithDiIBus(this IHealthChecksBuilder builder) { return(builder.AddTypeActivatedCheck <RabbitMQHealthCheckFromBus>($"RabbitMQHealthCheck_DI_IBUS")); }
public static IHealthChecksBuilder AddSystemInfoCheck(this IHealthChecksBuilder builder) { return(builder.AddTypeActivatedCheck <SystemInfoHealthChecks>($"SystemInfo")); }