use of com.codahale.metrics.health.HealthCheck in project dropwizard by dropwizard.
the class FakeApplication method run.
@Override
public void run(Configuration configuration, Environment environment) throws Exception {
environment.jersey().register(new FakeResource());
environment.healthChecks().register("fake-health-check", new HealthCheck() {
@Override
protected Result check() throws Exception {
return Result.healthy();
}
});
}
use of com.codahale.metrics.health.HealthCheck in project chassis by Kixeye.
the class MetricsConfiguration method healthCheckRegistry.
/***
* Initializes the health check registry
*
* @return health check registry bean
*/
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context) {
final HealthCheckRegistry bean = new HealthCheckRegistry();
// auto-register beans implementing health checks
Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
for (HealthCheck check : healthChecks.values()) {
bean.register(check.getClass().getName(), check);
}
return bean;
}
use of com.codahale.metrics.health.HealthCheck in project chassis by Kixeye.
the class ChassisConfiguration method healthCheckRegistry.
/**
* Initializes the health check registry
*
* @return health check registry bean
*/
@Bean
public HealthCheckRegistry healthCheckRegistry(ApplicationContext context, DiscoveryManager eureka) {
final HealthCheckRegistry bean = new HealthCheckRegistry();
// auto-register beans implementing health checks
Map<String, HealthCheck> healthChecks = context.getBeansOfType(HealthCheck.class);
for (HealthCheck check : healthChecks.values()) {
bean.register(check.getClass().getName(), check);
}
// connect health checks into Eureka
if (!disableEureka) {
eureka.getDiscoveryClient().registerHealthCheckCallback(new HealthCheckCallback() {
@Override
public boolean isHealthy() {
for (Entry<String, HealthCheck.Result> entry : bean.runHealthChecks().entrySet()) {
if (!entry.getValue().isHealthy()) {
return false;
}
}
return true;
}
});
}
return bean;
}
Aggregations