public HealthCheckBuilder AddCheck(string checkName, HealthCheck healthCheck)
        {
            if (string.IsNullOrWhiteSpace(checkName))
            {
                throw new ArgumentException("message", nameof(checkName));
            }

            if (healthCheck == null)
            {
                throw new ArgumentNullException(nameof(healthCheck));
            }

            _healthChecks.Add(checkName, healthCheck);
            return(this);
        }
        public static HealthCheckBuilder AddAppMetricsCheck(this HealthCheckBuilder builder, string name, string url, Func <HttpResponseMessage, ValueTask <IHealthCheckResult> > checkFunc)
        {
            if (builder == null)
            {
                throw new ArgumentNullException(nameof(builder));
            }

            if (url == null)
            {
                throw new ArgumentNullException(nameof(url));
            }

            if (checkFunc == null)
            {
                throw new ArgumentNullException(nameof(checkFunc));
            }

            builder.AddCheck($"Check({name})", HealthCheck.FromTaskCheck(() =>
            {
                var appmetricsChecker = new AppmetricsChecker(checkFunc, url);
                return(appmetricsChecker.CheckAsync());
            }));
            return(builder);
        }
 public async ValueTask <IHealthCheckResult> RunCheckAsync(HealthCheck healthCheck, CancellationToken cancellationToken = default(CancellationToken))
 {
     return(await healthCheck.CheckAsync(cancellationToken).ConfigureAwait(false));
 }