public IHealthRoot Build() { if (_options == null) { _options = new HealthOptions(); } if (_healthFormatterCollection.Count == 0) { _healthFormatterCollection.Add(new HealthStatusTextOutputFormatter()); } IRunHealthChecks healthCheckRunner; var health = new DefaultHealth(_checks.Values); var defaultMetricsOutputFormatter = _defaultMetricsHealthFormatter ?? _healthFormatterCollection.FirstOrDefault(); if (_options.Enabled && health.Checks.Any()) { healthCheckRunner = new DefaultHealthCheckRunner(health.Checks); } else { healthCheckRunner = new NoOpHealthCheckRunner(); } return(new HealthRoot( health, _options, _healthFormatterCollection, defaultMetricsOutputFormatter, healthCheckRunner)); }
public IHealthRoot Build() { if (_options == null) { _options = new HealthOptions(); } if (_healthFormatterCollection.Count == 0) { _healthFormatterCollection.Add(new HealthStatusTextOutputFormatter()); } IRunHealthChecks healthCheckRunner; var health = new DefaultHealth(_checks.Values); var defaultMetricsOutputFormatter = _defaultMetricsHealthFormatter ?? _healthFormatterCollection.FirstOrDefault(); if (_options.Enabled && health.Checks.Any()) { healthCheckRunner = new DefaultHealthCheckRunner(health.Checks); } else { healthCheckRunner = new NoOpHealthCheckRunner(); } if (string.IsNullOrWhiteSpace(_options.ApplicationName)) { var entryAssembly = Assembly.GetEntryAssembly(); _options.ApplicationName = entryAssembly?.GetName()?.Name?.Trim(); } return(new HealthRoot( health, _options, _healthFormatterCollection, defaultMetricsOutputFormatter, healthCheckRunner, _healthStatusReporters)); }