/** * Create a {@link CompositeHealthIndicator} based on the specified health indicators. * @param healthAggregator the {@link HealthAggregator} * @param healthIndicators the {@link HealthIndicator} instances mapped by name * @return a {@link HealthIndicator} that delegates to the specified * {@code healthIndicators}. */ public CompositeHealthIndicator createHealthIndicator( HealthAggregator healthAggregator, Map<String, HealthIndicator> healthIndicators) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); Assert.notNull(healthIndicators, "HealthIndicators must not be null"); HealthIndicatorRegistryFactory factory = new HealthIndicatorRegistryFactory( this.healthIndicatorNameFactory); return new CompositeHealthIndicator(healthAggregator, factory.createHealthIndicatorRegistry(healthIndicators)); }
public BootHealthCheckHandler(ApplicationInfoManager applicationInfoManager, HealthAggregator aggregator, Map<String, HealthIndicator> healthIndicators) { this.applicationInfoManager = Objects.requireNonNull(applicationInfoManager, "applicationInfoManager"); this.aggregateHealth = new CompositeHealthIndicator(aggregator, healthIndicators); }
public EurekaHealthCheckHandler(HealthAggregator healthAggregator) { Assert.notNull(healthAggregator, "HealthAggregator must not be null"); this.healthIndicator = new CompositeHealthIndicator(healthAggregator); }
@Bean @ConditionalOnMissingBean public HealthEndpoint healthEndpoint(HealthAggregator healthAggregator, HealthIndicatorRegistry registry) { return new HealthEndpoint( new CompositeHealthIndicator(healthAggregator, registry)); }
protected HealthIndicator createHealthIndicator(Map<String, S> beans) { if (beans.size() == 1) { return createHealthIndicator(beans.values().iterator().next()); } HealthIndicatorRegistry registry = new DefaultHealthIndicatorRegistry(); beans.forEach( (name, source) -> registry.register(name, createHealthIndicator(source))); return new CompositeHealthIndicator(this.healthAggregator, registry); }
@Bean @ConditionalOnMissingBean(name = "bindersHealthIndicator") public CompositeHealthIndicator bindersHealthIndicator() { return new CompositeHealthIndicator(new OrderedHealthAggregator(), new DefaultHealthIndicatorRegistry()); }
@Override public void afterBinderContextInitialized(String binderConfigurationName, ConfigurableApplicationContext binderContext) { if (this.bindersHealthIndicator != null) { OrderedHealthAggregator healthAggregator = new OrderedHealthAggregator(); Map<String, HealthIndicator> indicators = binderContext.getBeansOfType(HealthIndicator.class); // if there are no health indicators in the child context, we just mark // the binder's health as unknown // this can happen due to the fact that configuration is inherited HealthIndicator binderHealthIndicator = indicators.isEmpty() ? new DefaultHealthIndicator() : new CompositeHealthIndicator(healthAggregator, indicators); bindersHealthIndicator.getRegistry().register(binderConfigurationName, binderHealthIndicator); } }