/// <summary>
        /// Add a health check for single uri.
        /// </summary>
        /// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
        /// <param name="uri">The uri to check.</param>
        /// <param name="name">The health check name. Optional. If <c>null</c> the type name 'uri-group' will be used for the name.</param>
        /// <param name="failureStatus">
        /// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
        /// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
        /// </param>
        /// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
        /// <returns>The <see cref="IHealthChecksBuilder"/>.</returns></param>
        public static IHealthChecksBuilder AddUrlGroup(this IHealthChecksBuilder builder, Uri uri, string name = default, HealthStatus?failureStatus = default, IEnumerable <string> tags = default)
        {
            var options = new UriHealthCheckOptions();

            options.AddUri(uri);

            return(builder.Add(new HealthCheckRegistration(
                                   name ?? NAME,
                                   sp => new UriHealthCheck(options),
                                   failureStatus,
                                   tags)));
        }
        /// <summary>
        /// Add a health check for single uri.
        /// </summary>
        /// <param name="builder">The <see cref="IHealthChecksBuilder"/>.</param>
        /// <param name="uri">The uri to check.</param>
        /// <param name="name">The health check name. Optional. If <c>null</c> the type name 'uri-group' will be used for the name.</param>
        /// <param name="failureStatus">
        /// The <see cref="HealthStatus"/> that should be reported when the health check fails. Optional. If <c>null</c> then
        /// the default status of <see cref="HealthStatus.Unhealthy"/> will be reported.
        /// </param>
        /// <param name="tags">A list of tags that can be used to filter sets of health checks. Optional.</param>
        /// <returns>The <see cref="IHealthChecksBuilder"/>.</returns></param>
        public static IHealthChecksBuilder AddUrlGroup(this IHealthChecksBuilder builder, Uri uri, string name = default, HealthStatus?failureStatus = default, IEnumerable <string> tags = default)
        {
            builder.Services.AddHttpClient();

            var options = new UriHealthCheckOptions();

            options.AddUri(uri);

            var registrationName = name ?? NAME;

            return(builder.Add(new HealthCheckRegistration(
                                   registrationName,
                                   sp => CreateHealthCheck(sp, registrationName, options),
                                   failureStatus,
                                   tags)));
        }
        private static UriHealthCheck CreateHealthCheck <T>(IServiceProvider sp, string route)
            where T : ServiceDiscoveryClient
        {
            var serviceClient = sp.GetRequiredService <T>();

            if (serviceClient == null)
            {
                throw new NaosException($"Health: ServiceDiscovery client '{typeof(T)}' not found, please add with service.AddHttpClient<ServiceDiscoveryProxy>()");
            }

            var options = new UriHealthCheckOptions();
            var address = serviceClient.HttpClient?.BaseAddress?.ToString(); //.SubstringTill("servicediscovery");

            if (address.IsNullOrEmpty())
            {
                throw new NaosException($"Health: ServiceDiscovery client '{typeof(T)}' address not found, registration inactive (due to health) or missing from registry?");
            }

            options.AddUri(new Uri(new Uri(address), route));

            return(new UriHealthCheck(options, () => serviceClient.HttpClient));
        }