下面列出了怎么用org.springframework.boot.actuate.health.HealthAggregator的API类实例代码及写法,或者点击链接到github查看源代码。
@Autowired
public PipelineController(
ExecutionLauncher executionLauncher,
ExecutionRepository executionRepository,
ObjectMapper kayentaObjectMapper,
ConfigurableApplicationContext context,
HealthIndicatorRegistry healthIndicators,
HealthAggregator healthAggregator,
ScheduledAnnotationBeanPostProcessor postProcessor) {
this.executionLauncher = executionLauncher;
this.executionRepository = executionRepository;
this.kayentaObjectMapper = kayentaObjectMapper;
this.context = context;
this.healthIndicator = new CompositeHealthIndicator(healthAggregator, healthIndicators);
this.postProcessor = postProcessor;
}
public HealthMetricsConfiguration(HealthAggregator healthAggregator, List<HealthIndicator> healthIndicators,
MeterRegistry registry, PlatformTag platformTag) {
healthIndicator = new CompositeHealthIndicator(healthAggregator);
healthIndicators.forEach(h -> {
registry.gauge("health." + h.getClass().getSimpleName().replace("HealthIndicator", "").toLowerCase(),
platformTag.getTags(), h, HealthMetricsConfiguration::getStatusCode);
healthIndicator.addHealthIndicator(h.toString(), h);
});
registry.gauge("health", platformTag.getTags(), healthIndicator, HealthMetricsConfiguration::getStatusCode);
}
@Bean(BEAN_NAME)
public HealthIndicator diskSpaceHealthIndicator(HealthAggregator healthAggregator, DiskSpaceHealthProperties conf) {
if (logger.isInfoEnabled())
logger.info("Initial diskSpaceHealthIndicator. {}", conf);
AdvancedDiskSpaceHealthIndicator healthIndicator = new AdvancedDiskSpaceHealthIndicator(conf);
Map<String, Health> healths = new LinkedHashMap<String, Health>();
healths.put(AdvancedDiskSpaceHealthIndicator.class.getSimpleName(), healthIndicator.health());
return healthIndicator;
}
@Bean
public HealthIndicator timeoutsHealthIndicator(HealthAggregator healthAggregator, TimerMetricsProperties conf) {
if (conf.getSamples() == 0)
throw new IllegalArgumentException("Latest measure count is 0.");
if (logger.isInfoEnabled())
logger.info("Initial timeoutsHealthIndicator. {}", conf);
TimeoutsHealthIndicator healthIndicator = new TimeoutsHealthIndicator(conf);
Map<String, Health> healths = new LinkedHashMap<String, Health>();
healths.put(TimeoutsHealthIndicator.class.getSimpleName(), healthIndicator.health());
return healthIndicator;
}
@Bean(BEAN_NAME)
public HealthIndicator memoryHealthIndicator(HealthAggregator healthAggregator, MemoryHealthProperties conf) {
if (logger.isInfoEnabled())
logger.info("Initial memoryHealthIndicator. {}", conf);
AdvancedMemoryHealthIndicator healthIndicator = new AdvancedMemoryHealthIndicator(conf);
Map<String, Health> healths = new LinkedHashMap<String, Health>();
healths.put(AdvancedMemoryHealthIndicator.class.getSimpleName(), healthIndicator.health());
return healthIndicator;
}
@Bean(BEAN_NAME)
public HealthIndicator coreHealthIndicator(HealthAggregator healthAggregator, CpuHealthProperties conf) {
if (logger.isInfoEnabled())
logger.info("Initial CoreHealthIndicator. {}", conf);
AdvancedCpuHealthIndicator healthIndicator = new AdvancedCpuHealthIndicator(conf);
Map<String, Health> healths = new LinkedHashMap<String, Health>();
healths.put(AdvancedCpuHealthIndicator.class.getSimpleName(), healthIndicator.health());
return healthIndicator;
}
@Bean
HealthCheckHandler healthCheckHandler(
ApplicationInfoManager applicationInfoManager,
HealthAggregator healthAggregator,
Map<String, HealthIndicator> healthIndicators) {
return new BootHealthCheckHandler(applicationInfoManager, healthAggregator, healthIndicators);
}
public BootHealthCheckHandler(
ApplicationInfoManager applicationInfoManager,
HealthAggregator aggregator,
Map<String, HealthIndicator> healthIndicators) {
this.applicationInfoManager =
Objects.requireNonNull(applicationInfoManager, "applicationInfoManager");
this.aggregateHealth = new CompositeHealthIndicator(aggregator, healthIndicators);
}
@Bean
public HealthMetricsConfiguration healthMetricsConfiguration(HealthAggregator healthAggregator,
List<HealthIndicator> healthIndicators, MeterRegistry registry, PlatformTag platformTag) {
return new HealthMetricsConfiguration(healthAggregator, healthIndicators, registry, platformTag);
}
/** Registers health for any components, even those not in this jar. */
@Bean
ZipkinHealthIndicator zipkinHealthIndicator(HealthAggregator healthAggregator) {
return new ZipkinHealthIndicator(healthAggregator);
}
ZipkinHealthIndicator(HealthAggregator healthAggregator) {
super(healthAggregator);
}
@Bean
public HealthAggregator healthAggregator() {
return new OrderedHealthAggregator();
}